a = 1 a+2 import numpy as np import matplotlib.pyplot as plt from numpy import pi pi %matplotlib inline %matplotlib qt t = np.linspace(0, 4*pi) y = np.sin(t) plt.plot(t, y) # affiche y=f(t) plt.title('sinus') plt.xlabel('temps (s)') plt.grid(True) import pandas as pd %ls *.csv %pwd fname = 'log-20150128-092830.csv' !tail $fname # affiche *tout* le fichier dans le pager %more $fname # Afficher l'aide (syntaxe spécifique à la console IPython) pd.read_csv? d = pd.read_csv(fname, sep=';') d.head() d['date'][0] type(d['date'][0]) d = pd.read_csv(fname, sep=';', parse_dates=[[0,1]], # aller chercher la date dans les 2 première colonnes index_col=0, # utiliser la date comme index des données dayfirst=True, # ne pas confondre le 5 février avec le 2 mai (format américain MM-DD-YYYY) ) d.head() type(d) vals = d['value'] vals.head() type(vals) type_meas = d['type'] type_meas.unique() temp = vals[d['type'] == 'indoor temperature'] temp.head(3) co2 = vals[d['type'] == 'carbon dioxide'] co2.head(3) d.groupby('type').mean() temp.groupby(temp.index.dayofyear).mean() temp.resample('1D') temp.resample('1Min').head() temp.resample('1Min', fill_method='bfill').head() temp.resample('1Min').interpolate().head() %matplotlib inline temp.plot() plt.ylabel(u'température (°C)') # u'' pour des textes accentués temp.plot() plt.twinx() co2.plot(style='r'); fig, (ax1, ax2) = plt.subplots(2,1, sharex=True) temp.plot(ax=ax1) co2.plot(ax=ax2, style='r') plt.xlim('2015-02-03','2015-02-04') ax2.set_ylim(200, 1200);