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:24] Beretta, Anna Letizia |
python:first_course_statistics [2016/10/09 23:15] Francesco Beretta [International adoption rates (p.13)] |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== General instructions ====== | ||
+ | Read following important documentation about: | ||
+ | * pandas: accessing dataframes (tables) | ||
+ | * [[http://matplotlib.org/api/pyplot_summary.html|matplotlib.pyplot]] | ||
+ | Save your scripts in a folder inside the data folder, calling the script folder 'my_scripts' or whaterver. If 'my-scripts' is set as your [[python:generic_features#get_the_current_working_directory_address|current working directory]], then the data files are available under this address '../[data file]', for instantce: '../geyser1.TAB' | ||
====== Eruptions of the "Old Faithful" geyser (p.5) ====== | ====== Eruptions of the "Old Faithful" geyser (p.5) ====== | ||
Ligne 7: | Ligne 12: | ||
===== Histogram (p.5) ===== | ===== Histogram (p.5) ===== | ||
- | This is my first function. | + | 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 |
+ | gys1 = pd.DataFrame(pd.read_csv('../geyser1.TAB', '\t')) | ||
+ | g_int = gys1['Interval'] | ||
+ | ax = plt.gca() | ||
+ | ax.hist(g_int, bins=20, color='r') | ||
+ | ax.set_xlabel('Intereruption time') | ||
+ | ax.set_ylabel('Frequency') | ||
+ | ax.set_title('Histogram') | ||
+ | plt.show() | ||
+ | </code> | ||
- | csvfile = open('D:\data-wrangling-master\data-wrangling-master\data\chp3\data-text.csv', 'rb') | ||
- | reader = csv.reader(csvfile) | ||
- | |||
- | for row in reader: | ||
- | print(row) | ||
- | </code> | ||
+ | \\ | ||
====== International adoption rates (p.13) ====== | ====== International adoption rates (p.13) ====== | ||