In [1]:
%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

In [3]:
data=pd.read_csv("05_temp_rain_v2.csv")
#data.columns
#data

In [4]:
pivot=data.pivot_table(["rain(mm)","temp(dC)"], ["loc","month"])
pivot.head()


Out[4]:
rain(mm) temp(dC)
loc month
Adria_-_Bellombra 1 41.314286 2.933333
2 41.552381 4.280952
3 49.152381 8.733333
4 60.342857 13.038095
5 67.590476 18.185714

In [9]:
#pivot.xs("Agna", level=0)
locations=pivot.index.get_level_values(0).unique()
print(locations)
months=pivot.index.get_level_values(1).unique()
print(months)
print(len(months))

for location in locations:
    #print(pivot.xs(location, level=0))
    
    split=pivot.xs(location)
    rain=split["rain(mm)"]
    temp=split["temp(dC)"]
    
    plt.subplots()
    rain.plot(kind="bar").legend()
    plt.plot(range(len(temp)), temp, "r", label=temp.name)
    plt.legend()


['Adria_-_Bellombra' 'Agna' 'Agordo']
[ 1  2  3  4  5  6  7  8  9 10 11 12]
12