Last update: 17.10.2019 22:16:19
# 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=Z3nW8C0iT1Hh5QmJaDXxovEk9zVRjljk+XVK/IyMx8IlpKDR3e/sCzEpgEiBOWxuij6JOZQI+nzZm0qBc9gPZA==&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','Region','Country','ItemType','SalesChannel','OrderPriority','OrderDate','OrderID','ShipDate','UnitsSold','UnitPrice','UnitCost','TotalRevenue','TotalCost','TotalProfit' ]] = df['Table'].apply(pd.Series) #==================================================================== df["AIDate"] = pd.to_datetime(df["AIDate"]) df.set_index('AIDate', inplace=True) df.head() Region=df[['Region']] Country=df[['Country']] ItemType=df[['ItemType']] SalesChannel=df[['SalesChannel']] OrderPriority=df[['OrderPriority']] OrderDate=df[['OrderDate']] OrderID=df[['OrderID']] ShipDate=df[['ShipDate']] UnitsSold=df[['UnitsSold']] UnitPrice=df[['UnitPrice']] UnitCost=df[['UnitCost']] TotalRevenue=df[['TotalRevenue']] TotalCost=df[['TotalCost']] TotalProfit=df[['TotalProfit']] #==================================================================== df_rm = pd.concat([Region.rolling(12).mean(),Country.rolling(12).mean(),ItemType.rolling(12).mean(),SalesChannel.rolling(12).mean(),OrderPriority.rolling(12).mean(),OrderDate.rolling(12).mean(),OrderID.rolling(12).mean(),ShipDate.rolling(12).mean(),UnitsSold.rolling(12).mean(),UnitPrice.rolling(12).mean(),UnitCost.rolling(12).mean(),TotalRevenue.rolling(12).mean(),TotalCost.rolling(12).mean(),TotalProfit.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);