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


import os
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))

"""
After importing the necessary libraries and reading the file, import the file to python using pandas
"""
ic_flavors = pd.read_csv('/kaggle/input/icecream-shop-analysis/icecream_flavors.csv')
ic_sales = pd.read_csv('/kaggle/input/icecream-shop-analysis/icecream_sales.csv')
ic_temp = pd.read_csv('/kaggle/input/icecream-shop-analysis/icecream_temp.csv')
ic_sales_we = pd.read_csv('/kaggle/input/icecream-shop-analysis/sales_we.csv')

ic_files = [ic_flavors, ic_sales, ic_temp, ic_sales_we]
for files in ic_files:
    print(files.isna().sum())
    print(files.dtypes)
"""
There's no missing data on the files, but some of the datatypes need to be changed
"""
for files in ic_files:
    print(files.head())
ic_sales['date'] = pd.to_datetime(ic_sales['date'])
ic_flavors['flavor'] = ic_flavors['flavor'].astype('category')
ic_sales_we['date'] = pd.to_datetime(ic_sales_we['date'])
print(ic_flavors.head())
sns.lineplot(x = 'week', y = 'units sold', data = ic_flavors)
plt.title('Ice Cream Sold per day')
sns.countplot(x = 'flavor', data = ic_flavors)
plt.title('Ice Cream Flavors sold each week in 2019')
plt.show()
sns.lineplot(x = 'temperature', y = 'sales', data = ic_temp)
plt.title('Ice Cream Sales based on Temperature')
plt.show()
mean_sales_by_weekend = ic_sales_we.groupby('week_end')['sales'].mean()
print('Average sales by weekdays : '+ format(mean_sales_by_weekend[0]))
print('Average sales by weekends : '+ format(mean_sales_by_weekend[1]))