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]:
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()