Last update: 03.03.2019 11:13:12
# 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=ug9OJehIKUbnsnWE1BcXPOi6l6uS4SSmwLSWSYmzrXepZvTK2mXEnaPl+6PK0O4JJ68+RnR1DbMXVAczCp75yg==&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','policyID','statecode','county','eq_site_limit','hu_site_limit','fl_site_limit','fr_site_limit','tiv_2011','tiv_2012','eq_site_deductible','hu_site_deductible','fl_site_deductible','fr_site_deductible','point_latitude','point_longitude','line','construction','point_granularity' ]] = df['Table'].apply(pd.Series) #==================================================================== df["AIDate"] = pd.to_datetime(df["AIDate"]) df.set_index('AIDate', inplace=True) df.head() policyID=df[['policyID']] statecode=df[['statecode']] county=df[['county']] eq_site_limit=df[['eq_site_limit']] hu_site_limit=df[['hu_site_limit']] fl_site_limit=df[['fl_site_limit']] fr_site_limit=df[['fr_site_limit']] tiv_2011=df[['tiv_2011']] tiv_2012=df[['tiv_2012']] eq_site_deductible=df[['eq_site_deductible']] hu_site_deductible=df[['hu_site_deductible']] fl_site_deductible=df[['fl_site_deductible']] fr_site_deductible=df[['fr_site_deductible']] point_latitude=df[['point_latitude']] point_longitude=df[['point_longitude']] line=df[['line']] construction=df[['construction']] point_granularity=df[['point_granularity']] #==================================================================== df_rm = pd.concat([policyID.rolling(12).mean(),statecode.rolling(12).mean(),county.rolling(12).mean(),eq_site_limit.rolling(12).mean(),hu_site_limit.rolling(12).mean(),fl_site_limit.rolling(12).mean(),fr_site_limit.rolling(12).mean(),tiv_2011.rolling(12).mean(),tiv_2012.rolling(12).mean(),eq_site_deductible.rolling(12).mean(),hu_site_deductible.rolling(12).mean(),fl_site_deductible.rolling(12).mean(),fr_site_deductible.rolling(12).mean(),point_latitude.rolling(12).mean(),point_longitude.rolling(12).mean(),line.rolling(12).mean(),construction.rolling(12).mean(),point_granularity.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);