<jupyter_start><jupyter_text>0- run descriptive statistics on data<jupyter_code>data.describe()<jupyter_output><empty_output><jupyter_text>1- what is the average lifeExp per continent<jupyter_code>data.groupby('continent')['lifeExp'].mean()<jupyter_output><empty_output><jupyter_text>2- what is the average lifeExp per continent per year<jupyter_code>s = data.groupby(['continent', 'year'])['lifeExp'].mean()
s.head()
s.unstack('year')<jupyter_output><empty_output><jupyter_text>3- what is the average length of country name per continent and year<jupyter_code>data['country_nl'] = data['country'].apply(len)
data.head()
data.groupby(['continent', 'year'])['country_nl'].mean()
def my_agg(series_of_string):
    lengths = [len(s) for s in series_of_string]
    return sum(lengths) / len(series_of_string)
my_agg(["UK", "France"])
#list(data.groupby(['continent', 'year'])['country'])[0]
data.groupby(['continent', 'year'])['country'].aggregate(my_agg)<jupyter_output><empty_output><jupyter_text>4- what are the countries in which the averalge lifeExp over their observations is greater than 75 years<jupyter_code>avg_life = data.groupby('country')['lifeExp'].mean()
set(avg_life[avg_life > 75].index)
set(
    data[data.groupby('country')['lifeExp'].transform(
    lambda x: x.mean() > 75)
    ]['country']
)
set(
    data.loc[
    data.groupby('country')['lifeExp'].filter(
        lambda x: x.mean() > 75).index
]['country']
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17078189300411523, 'fraction_numerical': 0.009602194787379973, 'mean_word_length': 7.5321637426900585, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 24, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '155353', 'license': 'MIT', 'n_tokens_mistral': 527, 'n_tokens_neox': 511, 'n_words': 95, 'path': '21-warmup-solution_aggregation_and_grouping.ipynb', 'repo_name': 'hanisaf/advanced-data-management-and-analytics', 'size': '1458'}