# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pandas as pd

import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np

# %matplotlib inline

# # DataLit Homework Assignment Week 4
# Historical sales data from 45 stores. This dataset comes from KAGGLE (https://www.kaggle.com/manjeetsingh/retaildataset).
#

# +
# Stores
# Contains anonymized information about the 45 stores, indicating the type and size of store.
stores = 'dataset/stores data-set.csv'

# feature
# Contains additional data related to the store, department, and regional activity for the given dates.
feature = 'dataset/Features data set.csv'

# Sales
# Contains historical sales data, which covers to 2010-02-05 to 2012-11-01.
sales = 'dataset/sales data-set.csv'

data_stores = pd.read_csv(stores)
data_feature = pd.read_csv(feature)
data_sales = pd.read_csv(sales)
# -

data_stores.head()

data_feature.head()

data_sales.head()

#drop all Markdowns inside data_feature
data_feature.drop(['MarkDown1','MarkDown2','MarkDown3','MarkDown4','MarkDown5'], axis='columns',inplace=True)

data_feature.head()

# +
# Merge the data in a unique DataFrame
df = pd.merge(pd.merge(data_feature, data_sales, on=['Store', 'Date', 'IsHoliday']), data_stores, on=['Store'])

# Convert Date to pandas Date format
df['Date'] = pd.to_datetime(df['Date'])
df.head()
# -

df.dtypes

df.shape

df.Type.value_counts()

# +
# df_average_sales_week = df.groupby(by=['Date'], as_index=False)['Weekly_Sales'].sum()
# df_average_sales = df_average_sales_week.sort_values('Weekly_Sales', ascending=False)

# plt.figure(figsize=(15,5))
# plt.plot(df_average_sales_week.Date, df_average_sales_week.Weekly_Sales)
# plt.show()
# -

df.groupby([df.Date.dt.year,df.Date.dt.month]).Weekly_Sales.mean()

df.groupby(df.Date.dt.year).Weekly_Sales.mean()

df.groupby([df.Date.dt.year,df.Date.dt.month]).Weekly_Sales.mean().plot()

# +
# fig_size = plt.rcParams["figure.figsize"]
# plt.plot( df.Date, df.Weekly_Sales,'o-')
# fig_size[0] = 14
# fig_size[1] = 4
# plt.rcParams["figure.figsize"] = fig_size
# plt.ylabel('Label 1')

# plt.show()

fig, ax = plt.subplots()
ax.plot( df.Date.dt.year, df.Weekly_Sales)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
       title='About as simple as it gets, folks')
ax.grid()

#fig.savefig("test.png")
plt.show()
# -

df.describe().transpose()







StarcoderdataJupyterScriptsDedupFiltered