Please tell me the solution to the problem: I have the following list, obtained through json:
'Sides': [{ 'ShortName': 'АО "Компания 1', 'Type': 0, 'Inn': '7777777771', 'Ogrn': '1111111111111', }, {'ShortName': 'ООО "Компания 2', 'Type': 1, 'Inn': '77777777772', 'Ogrn': '55555555555'}] The goal is to write a function that will transfer data to DataFrame according to Type: i.e. if Type 0, then data from the corresponding dictionary is taken.
def Paintiff(Sides): if len(Sides) > 0: for data in Sides: if data['Type'] == 0: return data['ShortName'], data['Inn'], data['Ogrn'] return None for company in companies: c = { 'ShortName_Plantiff': Paintiff(company['Sides']), 'ShortName_Defendant': Paintiff(company['Sides']) 'Inn': Paintiff(company['Sides'] 'ogrn': Paintiff(company['Sides'] } df_raw = df_raw.append(c, ignore_index=True) I tried to write the code (above), but it turns out that he takes only the first name of the company and nothing more :(