Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
python:first_course_statistics [2016/10/08 13:10] Beretta, Anna Letizia |
python:first_course_statistics [2016/10/09 23:06] Francesco Beretta |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== General instructions ====== | ||
+ | |||
+ | Read following important documentation about: | ||
+ | * pandas: accessing dataframes (tables) | ||
+ | * [[http://matplotlib.org/api/pyplot_summary.html|matplotlib.pyplot]] | ||
Ligne 6: | Ligne 11: | ||
===== Histogram (p.5) ===== | ===== Histogram (p.5) ===== | ||
+ | |||
+ | FB: this script works fine ! | ||
<code python> | <code python> | ||
- | # fake code – to be deleted | + | import pandas as pd |
- | import csv | + | import matplotlib.pyplot as plt |
- | filename = 'ch02-data.csv' | + | gys1 = pd.DataFrame(pd.read_csv('../geyser1.TAB', '\t')) |
- | f = open(filename) | + | g_int = gys1['Interval'] |
- | data = [] | + | ax = plt.gca() |
- | reader = csv.reader(f) | + | ax.hist(g_int, bins=20, color='r') |
- | header = reader.next() | + | ax.set_xlabel('Intereruption time') |
- | data = [row for row in reader] | + | ax.set_ylabel('Frequency') |
- | for datarow in data: | + | ax.set_title('Histogram') |
- | print datarow | + | plt.show() |
</code> | </code> | ||