In [1]:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
df_sz = pd.read_csv('data/sz-daily-2015.csv')
df_sz.index = pd.to_datetime(df_sz.date)
df_sz.drop('date', axis=1, inplace=True)
In [3]:
df_sz.head()
Out[3]:
In [4]:
df_sz.PM10.plot()
df_sz.PM2_5.plot()
plt.axhline(y=50, color='r', label='Grenzwert')
plt.xlabel('Datum')
plt.ylabel('Feinstaub $\mu g / m^3$')
plt.legend()
_ = plt.title('Schwabenzentrum')
In [5]:
corr = df_sz.corr()
# Generate a mask for the upper triangle
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
# Generate a custom diverging colormap
#cmap = sns.diverging_palette(220, 10, as_cmap=True)
cmap = sns.color_palette("RdBu_r", 12)
# Draw the heatmap with the mask and correct aspect ratio
#sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,
# square=True, linewidths=.5, cbar_kws={"shrink": .5})
sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,
square=True, linewidths=.5, cbar_kws={"shrink": .5});
In [6]:
pm_ratio = df_sz.PM10 / df_sz.PM2_5
pm_ratio.plot();
In [7]:
tage = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']
df_sz.PM10.groupby(df_sz.index.dayofweek).agg(['min','mean', 'median', 'max'])
Out[7]:
In [8]:
ax = sns.boxplot(x=df_sz.index.weekday_name, y='PM10', data=df_sz)
ax.set_xticklabels(tage)
plt.xlabel('Wochentag');
In [9]:
df_nt = pd.read_csv('data/neckartor-daily-2016.csv')
df_nt.index = pd.to_datetime(df_nt.date)
df_nt.drop('date', axis=1, inplace=True)
In [10]:
ax = sns.boxplot(x=df_nt.index.dayofweek, y='PM10', data=df_nt)
ax.set_xticklabels(tage);
plt.xlabel('Wochentag');