<jupyter_start><jupyter_text>Pandas experimentsPandas are an acquired taste. This document contains some demonstrations and experiments that create and manipulatePanda datastructures (Serie, Dataset)  Series  Creating<jupyter_code>serie1 = pd.Series([1,2,3,4])
serie1
serie2 = pd.Series({'a':1, 'b':2, 'c':3})
serie2<jupyter_output><empty_output><jupyter_text>DataFrame  Creating<jupyter_code>d = {
    'one': pd.Series([1., 2., 3.], index=['a', 'b', 'c']), 
    'two': pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}
df = pd.DataFrame(d)
df<jupyter_output><empty_output><jupyter_text>Reading a CSV file<jupyter_code>csv = pd.read_csv("data/stats_weekofyear.gz")

csv.head()<jupyter_output><empty_output><jupyter_text>Some Selections (create a series)<jupyter_code>s = csv['all']
s<jupyter_output><empty_output><jupyter_text>Grouping<jupyter_code>gcsv = csv.groupby(['year', 'weekofyear']).sum()
gcsv<jupyter_output><empty_output><jupyter_text>Pivotting<jupyter_code>pcsv = csv.pivot(index='weekofyear', columns='year', values='all')
pcsv
y2016 = pcsv[2016].tolist()
y2017 = pcsv[2017].tolist()
y2018 = pcsv[2018].tolist()
y2019 = pcsv[2019].tolist()

x = np.arange(4)
width = 0.35

fig, ax = plt.subplots()
bar2016 = ax.bar(x - 2*(width/4), y2016, width, label='2016')
bar2017 = ax.bar(x - (width/4), y2017, width, label='2017')
bar2018 = ax.bar(x + (width/4), y2018, width, label='2018')
bar2019 = ax.bar(x + (2*width/4), y2019, width, label='2019')

plt.show
p1 = y2019.plot(kind='bar')<jupyter_output><empty_output><jupyter_text>plotting<jupyter_code>csv.plot(kind='scatter', x='year', y='teacher')
# pcsv.plot(lind='line', x='year', y='all')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1946587537091988, 'fraction_numerical': 0.06706231454005934, 'mean_word_length': 7.558375634517766, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '192032', 'license': 'MIT', 'n_tokens_mistral': 773, 'n_tokens_neox': 692, 'n_words': 114, 'path': 'notebooks/experiments.ipynb', 'repo_name': 'Janvanoorschot/anarobo', 'size': '1685'}