File size: 1,317 Bytes
f556b0c
 
 
 
 
 
 
 
1f22e94
f556b0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def check_spark(row, col_name='name', types=['Игристое', 'игр']):
    if col_name in row.keys():
        for t in types:
            if t.lower() in row[col_name].lower() and 'Пилигрим' not in row[col_name].lower():
                return 'Игристое'
        return None


def check_color_and_sour(row, col_name='type_wine', types=['Белое', 'Розовое', 'Красное', 'крас.', 'бел.']):
    if col_name in row.keys():
        for t in types:
            if t.lower() in row[col_name].lower():
                return 'Вино'
        return None


def is_type_exist(row, types):
    for t in types:
        if t.lower() in row['type'].lower():  # Сравнение без учета регистра
            return t
    return None

def check_type(row, types):
    #checker=False
    for t in types:
        if t.lower() in row['name'].lower():  # Сравнение без учета регистра
            return t
    return None

def get_type(row, types):
    if 'type' not in row.keys():
      return check_type(row, types)
    elif 'type' in row.keys():
      semi_res=is_type_exist(row, types)
      if semi_res!=None:
        return semi_res
      else:
        return check_type(row, types)
    return None