%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn

pd.options.display.max_rows = 8

"""
Explanation: <CENTER>

<header>
    <h1>Pandas Tutorial</h1>
    <h3>EuroScipy, Cambridge UK, August 27th, 2015</h3>
    <h2>Joris Van den Bossche</h2>
    <p></p>
Source: <a href="https://github.com/jorisvandenbossche/2015-EuroScipy-pandas-tutorial">https://github.com/jorisvandenbossche/2015-EuroScipy-pandas-tutorial</a>
  </header>
</CENTER>
About me: Joris Van den Bossche

PhD student at Ghent University and VITO, Belgium
bio-science engineer, air quality research
pandas core dev

->

https://github.com/jorisvandenbossche
@jorisvdbossche

Licensed under CC BY 4.0 Creative Commons
Content of this talk

Why do you need pandas?
Basic introduction to the data structures
Guided tour through some of the pandas features with two case studies: movie database and a case study about air quality

If you want to follow along, this is a notebook that you can view or run yourself:

All materials (notebook, data, link to nbviewer): https://github.com/jorisvandenbossche/2015-EuroScipy-pandas-tutorial
You need pandas >= 0.15.2 (easy solution is using Anaconda)

Some imports:
End of explanation
"""


data = pd.read_csv('data/airbase_data.csv', index_col=0, parse_dates=True)

data

"""
Explanation: Let's start with a showcase
Case study: air quality in Europe
AirBase (The European Air quality dataBase): hourly measurements of all air quality monitoring stations from Europe
Starting from these hourly data for different stations:
End of explanation
"""


data['1999':].resample('A').plot(ylim=[0,100])

"""
Explanation: to answering questions about this data in a few lines of code:
Does the air pollution show a decreasing trend over the years?
End of explanation
"""


exceedances = data > 200
exceedances = exceedances.groupby(exceedances.index.year).sum()
ax = exceedances.loc[2005:].plot(kind='bar')
ax.axhline(18, color='k', linestyle='--')

"""
Explanation: How many exceedances of the limit values?
End of explanation
"""


data['weekday'] = data.index.weekday
data['weekend'] = data['weekday'].isin([5, 6])
data_weekend = data.groupby(['weekend', data.index.hour])['FR04012'].mean().unstack(level=0)
data_weekend.plot()

"""
Explanation: What is the difference in diurnal profile between weekdays and weekend?
End of explanation
"""


