<jupyter_start><jupyter_text>Plot % of zero activity per borough/region<jupyter_code>do_all = False

with sns.axes_style('whitegrid'):
    for area in areas:
        if not do_all and area != 'Southwark':
            continue
        fig, ax = plt.subplots(figsize=(11, 7), nrows=1, ncols=1)
        df_area = df_zero[df_zero['area'] == area]
        if len(df_area) > 0:
            df_area.dropna()['percentage'].plot(ax=ax)
            ax.yaxis.set_major_formatter(FuncFormatter(lambda y, _: '{:.2%}'.format(y)))
            ax.legend(loc='lower left')
            ax.set_title(area)
            plt.tight_layout()
            plt.show()<jupyter_output><empty_output><jupyter_text>Curvature index**Goal**: to be able to compare boroughs in terms of the impact of the Olympics on the sport participation; ideally, produce a single number to quantify the impact and its durability.**Methodology**:For many boroughs, it seems the year 2011-2012 witnessed a decrease in the 'zero' population, i.e a larger fraction of people exercised at least once in the week.This surge in sport activity seems to have reverted in the years after.We compute a curvature index:* ((mean of 'zero' % after - 'zero' % @2011-2012) - ('zero' % @2011-2012 - mean of 'zero' % before)) / 2In case of transient impact, the curvature at 2011-2012 should be high, indicating a peak in sport participation that quickly reverted.**Results**:The year 2012 corresponds indeed to a peak in sport participation, most likely driven by renewed interest in sports at the time of the Olympics and possibly local policies to promote sport and sport infrastructure. The curvature index is positive for many boroughs, indicating a transient impact (for instance the pro-sport policies may have only lasted for the summer 2012).<jupyter_code>sport_min_year = dict()
# sport_slope = dict()
sport_curvature = dict()

for area in areas:
    df_area = df_zero[df_zero['area'] == area]
    if len(df_area) > 0:
        sport_min_year[area] = df_area['percentage'].idxmin()
#         sport_slope[area] = (df_area.iloc[:6].mean()['percentage'] - df_area.iloc[5:].mean()['percentage'])
        sport_curvature[area] = (
            (df_area.iloc[6:].mean()['percentage'] - df_area.iloc[5]['percentage']) - (df_area.iloc[5]['percentage'] - df_area.iloc[:5].mean()['percentage'])
        ) / 2
sport_min_year = pd.Series(sport_min_year).sort_values()
# sport_slope = pd.Series(sport_slope).sort_values()
sport_curvature = pd.Series(sport_curvature).sort_values()

with sns.axes_style('whitegrid'):
    fig, axes = plt.subplots(figsize=(11, 14), nrows=2, ncols=1)
    
    ax = axes[0]
    sport_min_year.hist(ax=ax, bins=len(years))
    ax.set_title('Sport Best Year')
    
#     ax = axes[1]
#     sport_slope.plot.bar(ax=ax)
#     ax.set_title('Sport Slope Index')

    ax = axes[1]
    sport_curvature.plot.bar(ax=ax)
    ax.set_title('Sport Curvature Index')
    plt.tight_layout()
    plt.show()<jupyter_output><empty_output><jupyter_text>Total plot<jupyter_code>with sns.axes_style('whitegrid'):
    fig, ax = plt.subplots(figsize=(11, 7), nrows=1, ncols=1)
#     df_zero[df_zero['area'] == 'Southwark'].dropna().sort_values('year')[['year', 'percentage']].set_index('year').plot(ax=ax)
    df_zero.groupby('year').mean().sort_values('year')['percentage'].plot(ax=ax, color='r', label='zero')
    df_one.groupby('year').mean().sort_values('year')['percentage'].plot(ax=ax, color='b', label='one+')
    df_three.groupby('year').mean().sort_values('year')['percentage'].plot(ax=ax, color='g', label='three')
    ax.yaxis.set_major_formatter(FuncFormatter(lambda y, _: '{:.2%}'.format(y)))
    ax.legend(loc='lower left')
    plt.tight_layout()
    plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1481283422459893, 'fraction_numerical': 0.01898395721925134, 'mean_word_length': 4.329059829059829, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '303016', 'license': 'MIT', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1245, 'n_words': 295, 'path': 'notebook/ldn_sport_participation.ipynb', 'repo_name': 'louis-lapassat/summer_invitational_data_open_2020', 'size': '3740'}