<jupyter_start><jupyter_text>Subsetting<jupyter_code>country_df = df['country']
country_df.head()
country_df.tail()
type(country_df)
subset = df[['country', 'continent', 'year']]
subset.head()
pandas.__version__
df[[0, 1]]
df.head()
df.loc[0]
df.loc[[0, 99]]
df.loc[-1]
df.iloc[0]
df.iloc[[0, 99]]
df.iloc[-1]
df.ix[0]
df.ix[0]
subset = df.loc[:, ['year', 'pop']]
subset.head()
subset = df.iloc[:, [2, 4]]
subset.head()
subset = df.iloc[-5::2, :3]
subset<jupyter_output><empty_output><jupyter_text>grouped calculations<jupyter_code>df.head()
df.groupby('year')['lifeExp'].mean()
df.groupby(['year', 'continent'])[['lifeExp', 'gdpPercap']].mean()
df\
    .groupby(['year', 'continent'])[['lifeExp', 'gdpPercap']]\
    .mean()\
    .reset_index()
(df
    .groupby(['year', 'continent'])\
     [['lifeExp', 'gdpPercap']]\
    .mean()\
    .reset_index()
)
(df
    .groupby(['year'])\
     [['lifeExp']]\
    .mean()\
    .plot()
)
import matplotlib.pyplot as plt
plt.show()
%matplotlib inline<jupyter_output><empty_output><jupyter_text>this is a plot of avg lifeExp over time across the world<jupyter_code>df.info()
df.memory_usage()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2267241379310345, 'fraction_numerical': 0.016379310344827588, 'mean_word_length': 5.414364640883978, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '107503', 'license': 'MIT', 'n_tokens_mistral': 499, 'n_tokens_neox': 494, 'n_words': 80, 'path': 'notebooks/01-pandas_intro.ipynb', 'repo_name': 'chendaniely/2017-12-04-pandas_live', 'size': '1160'}