In [1]:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
%matplotlib inline
In [2]:
!wget http://www.metoffice.gov.uk/pub/data/weather/uk/climate/stationdata/oxforddata.txt
In [3]:
!head oxforddata.txt
In [4]:
df = pd.read_csv("oxforddata.txt", header=5, skiprows=[6],
usecols=[0, 1, 5], skipinitialspace=True,
comment='P', # Ignore the 'Provisional statement'
engine='c', dtype=None, delim_whitespace=True)
df = df.applymap(lambda x:float(str(x).rstrip('*'))) # Remove *'s
df.head()
Out[4]:
In [5]:
grouped = df.groupby('mm')['rain'].mean()
ax = grouped.plot(kind='bar', x='mm', y='rain')
ax.set_xlabel("Month")
ax.set_ylabel("Amount of rain in mm")
Out[5]:
In [16]:
January = df[df.mm == 5]
fig, ax = plt.subplots(figsize=(14, 5))
ax.plot(January.yyyy.values, January.rain.values, "-o", color='k')
plt.show()
In [ ]: