<jupyter_start><jupyter_text>We consider individual entities with non-zero interest in most of the countries<jupyter_code>tmp = df_results.groupby('name').apply(lambda x: pd.Series({
    'corr_avg': x['corr'].mean(), 
    'category': x['category'].unique()[0],
    'exists_most_countries': len(x)>=10,
    'country': x['country'], 
    'corr': x['corr'],
    'p': x['p'],
    'all': x[['country','corr','p']]
    })).reset_index()
tmp = tmp.loc[tmp['exists_most_countries']]
tmp.sort_values(by = 'corr_avg', ascending =  False).head(10)[['name','corr_avg','category']]
tmp.sort_values(by = 'corr_avg').head(10)[['name','corr_avg','category']]
top_entities = tmp.sort_values(by = 'corr_avg', ascending =  False).head(10)[['name','corr_avg','category']]['name'].values
top_entities
for entity in top_entities:
    t = df_results.loc[df_results['name']==entity].sort_values(by = 'country')
    print(len(t))
    
    missing = []
    for i in full_names.keys():
        if i not in t['country'].values:
            missing.append(i)
    if len(t)<18:
        print(missing)
        
    print(entity+' ('+t.iloc[0]['category']+') & corr avg &') 
    
    for c,row in t.iterrows():
        print(str(round(row['corr'],2)) + make_stars(row['p']) + ' &')
    
    print('----------------------------------')
    print('\n')
    

for i,row in tmp.sort_values(by = 'corr_avg', ascending =  False).head(10)[['name','corr_avg','country','corr','p','category']].iterrows():
    print(row['name']+' ('+row['category']+') & ')
    print(round(row['corr_avg'],2),' & ')
    

    
tmp.sort_values(by = 'corr_avg', ascending =  True).head(10)[['name','corr_avg','category']]
top_entities = tmp.sort_values(by = 'corr_avg').head(10)[['name','corr_avg','category']]['name'].values
top_entities
for entity in top_entities:
    t = df_results.loc[df_results['name']==entity].sort_values(by = 'country')
    print(len(t))
    
    missing = []
    for i in full_names.keys():
        if i not in t['country'].values:
            missing.append(i)
    if len(t)<18:
        print(missing)
        
    print(entity+' ('+t.iloc[0]['category']+') & corr avg &') 
    
    for c,row in t.iterrows():
        print(str(round(row['corr'],2)) + make_stars(row['p']) + ' &')
    
    print('----------------------------------')
    print('\n')
    
for i,row in tmp.sort_values(by = 'corr_avg').head(10)[['name','corr_avg','country','corr','p','category']].iterrows():
    print(row['name']+' ('+row['category']+') & ')
    print(round(row['corr_avg'],2),' & ')
df = pd.read_parquet(DATA_DIR+'modes_timeseries.parquet')
df = df.loc[df['country_code'].isin(full_names.keys())]
entry_list = []

c = 0
for category, gr1 in df.groupby('name'):
    for country, gr2 in gr1.groupby('country_code'):
        c+=1
        entry = {}
        y = list(mobility_ts[country].values())
        #x = list(gr2.iloc[0]['ts']['max_ratio'].values())[-46:]
        
        x = (np.array(list(gr2.iloc[0]['ts']['max_ratio'].values())[-46:]) - np.array(list(gr2.iloc[0]['ts']['max_ratio'].values())[-98:-52]) - 0.00001) /\
            (np.array(list(gr2.iloc[0]['ts']['max_ratio'].values())[-98:-52]) + 0.00001)
        entry['name'] = category
        entry['category'] = gr2.iloc[0]['category']
        entry['country'] = country
        entry['corr'] = spearmanr(x,y)[0]
        entry['p'] = spearmanr(x,y)[1]
        
        entry_list.append(entry)
df_results_modes = pd.DataFrame(entry_list)
tmp = df_results_modes.groupby('name').apply(lambda x: pd.Series({
    'corr_avg': x['corr'].mean(), 
    'category': x['category'].unique()[0],
    'C': x['country'].unique(),
    'all': x[['country','corr','p']]
    })).reset_index()

tmp.sort_values(by = 'corr_avg', ascending =  False)[['name','corr_avg','category']]<jupyter_output><empty_output><jupyter_text>Print correlations in latex formatting<jupyter_code>for i,row in tmp.sort_values(by = 'corr_avg', ascending =  False)[['name','corr_avg','category','all']].iterrows():
    print(row['name'])
    print(row['category'])
    print(round(row['corr_avg'],2))
    

    if row['name']=='Lunchbox':
        for c,r in row['all'].iloc[:17].iterrows():
            print( '&',str(round(r['corr'],2))+make_stars(r['p']))
    else:
        for c,r in row['all'].iterrows():
            print( '&',str(round(r['corr'],2))+make_stars(r['p']))
    print('----------------------------------')
    print('\n')<jupyter_output>Recipe
Mode 1
0.7
& 0.88*
& 0.87*
& 0.73*
& 0.74*
& 0.73*
& 0.45*
& 0.81*
& 0.72*
& 0.85*
& 0.76*
& 0.82*
& 0.85*
& 0.04
& 0.66*
& 0.95*
& 0.47*
& 0.61*
& 0.68*
----------------------------------


Baking
Mode 1
0.62
& 0.88*
& 0.8*
& 0.71*
& 0.55*
& 0.28
& 0.41*
& 0.64*
& 0.43*
& 0.88*
& 0.71*
& 0.91*
& 0.46*
& 0.17
& 0.77*
& 0.79*
& 0.47*
& 0.55*
& 0.77*
----------------------------------


Cooking
Mode 1
0.58
& 0.75*
& 0.67*
& 0.6*
& 0.39*
& 0.23
& 0.08
& 0.87*
& 0.61*
& 0.88*
& 0.63*
& 0.84*
& 0.75*
& 0.26
& 0.66*
& 0.83*
& 0.37*
& 0.34*
& 0.62*
----------------------------------


Take-out
Mode 2
0.5
& 0.8*
& 0.66*
& 0.64*
& 0.56*
& 0.73*
& 0.07
& 0.1
& 0.62*
& 0.33*
& 0.42*
& 0.31*
& 0.79*
& 0.8*
& 0.08
& 0.49*
& 0.03
& 0.63*
& 0.88*
----------------------------------


Grocery store
Mode 1
0.28
& 0.14
& 0.32*
& 0.64*
& 0.41*
& 0.32*
& 0.07
& 0.12
& -0.29*
& 0.64*
& 0.38*
& 0.8*
& 0.46*
& 0.15
& 0.36*
& -0.28
& 0.35*
& 0.16
& 0.39*
----------------------------------


Supermarket
[...]