Last update: 03.03.2019 11:22:18
# Sample code generated by DasData www.DasData.co import requests import pandas as pd import matplotlib.pyplot as plt plt.style.use('seaborn-whitegrid') import numpy as np %matplotlib inline data_url = 'https://DasData.co/e.aspx?das=s0DtFd/8/IhL+ROHuRx5oidvMEZTaZH76KgnVmQRlyz027WTzEH6q/xqRErmk7KlfO2y1bUWQMsDx8EDMFnFqw==&from=0&to=500&json=1' response = requests.get(data_url, data={"limit" : "500"}) if response.status_code == 200: df = pd.DataFrame.from_records(response.json()) print(df) #==================================================================== df[['id','AIDate','Year','Flood' ]] = df['Table'].apply(pd.Series) #==================================================================== df["AIDate"] = pd.to_datetime(df["AIDate"]) df.set_index('AIDate', inplace=True) df.head() Year=df[['Year']] Flood=df[['Flood']] #==================================================================== df_rm = pd.concat([Year.rolling(12).mean(),Flood.rolling(12).mean()], axis=1) #==================================================================== df_rm.plot(figsize=(20,10), linewidth=2, fontsize=15) x = np.linspace(0, 10, 50) plt.xlabel('AIDate', fontsize=12);