Created
January 24, 2017 21:33
-
-
Save selahlynch/3d57f66d07d60cd21d8840a2d0bb41be to your computer and use it in GitHub Desktop.
Generate climate data graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib qt | |
import pandas as pd | |
df = pd.read_csv("/home/selah/Data/PHL climate data.csv") | |
#df.plot(use_index=True,y='TMAX',grid=True) | |
import matplotlib.pyplot as plt | |
import datetime as dt | |
f = lambda d: dt.datetime.strptime(str(d), '%Y%m%d').date() | |
dates = df.DATE.apply(f) | |
import matplotlib.dates as mdates | |
ax=plt.gca() | |
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m/%d/%Y')) | |
ax.xaxis.set_major_locator(mdates.DayLocator()) | |
#plt.plot(dates, df.TMAX) | |
plt.plot(dates, pd.rolling_mean(df.TMAX, 90, center=True), label='90 day rolling average') | |
plt.plot(dates, pd.rolling_mean(df.TMAX, 365, center=True), label='365 day rolling average') | |
plt.grid(True) | |
plt.legend() | |
plt.title("Temperature at PHL International Airport") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment