import pandas as pd
import pandas as pd
df_followers = pd.read_json('followers_and_following/restricted_accounts.json')
cols = ['Cuenta IG', 'URL De Cuenta']
list_values = []
relationships = df_followers["relationships_restricted_users"]
relationships
for relationship in relationships:
for value in relationship['string_list_data']:
list_values.append([value['value'],value['href']])
print('Los valores han sido añadidos a la lista')
restricted_accounts_df = pd.DataFrame(list_values, columns=cols)
restricted_accounts_df.drop_duplicates(inplace=True)
restricted_accounts_df['Cuenta IG'] = restricted_accounts_df['Cuenta IG'].astype('string')
restricted_accounts_df['URL De Cuenta'] = restricted_accounts_df['URL De Cuenta'].astype('string')
print(restricted_accounts_df['Cuenta IG'].dtype)
restricted_accounts_df
restricted_accounts_df.to_csv('restricted_accounts_ayudinga.csv', sep='\t', encoding='utf-8')