text_plain_output_1.png
import datetime

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

train = pd.read_csv('../input/train.csv')

train_sample = train.sample(frac=0.05)

holiday_events = pd.read_csv('../input/holidays_events.csv')
items = pd.read_csv('../input/items.csv')
oil = pd.read_csv('../input/oil.csv')
stores = pd.read_csv('../input/stores.csv')
test = pd.read_csv('../input/test.csv')
transactions = pd.read_csv('../input/transactions.csv')

import datetime
train_sample['date'] = train_sample['date'].apply(datetime.datetime.strptime, args=('%Y-%m-%d',))
train_sample.sort_values(by='date', inplace=True)

daily_sale = pd.DataFrame()
daily_sale['count'] = train_sample['date'].value_counts()
daily_sale['date'] = train_sample['date'].value_counts().index
daily_sale = daily_sale.sort_values(by='date')
unit_sale = pd.DataFrame()
unit_sale['count'] = train_sample[train['unit_sales'] > 0]['unit_sales'].value_counts()
unit_sale['positive_unit_sales'] = train_sample[train['unit_sales'] > 0]['unit_sales'].value_counts().index
unit_sale = unit_sale.sort_values(by='positive_unit_sales')

promotion_count = pd.DataFrame()
promotion_count['count'] = train_sample['onpromotion'].value_counts()

fig, (ax1,ax2,ax3) = plt.subplots(1,3,figsize = (18,5))
sns.set_style('darkgrid')
ax1.plot(daily_sale['date'], daily_sale['count'])
ax1.set_xlabel('date', fontsize=15)
ax1.set_ylabel('count', fontsize=15)
ax1.tick_params(labelsize=15)
sns.barplot(x = promotion_count.index, y = promotion_count['count'],ax = ax2)
ax2.set_ylabel('count', fontsize = 15)
ax2.set_xlabel ('onpromotion',fontsize =15)
ax2.tick_params(labelsize = 15)
ax2.ticklabel_format(style = 'sci',scilimits = (0,0), axis = 'y')
plt.subplot(1,3,3)
plt.loglog(unit_sale['positive_unit_sales'], unit_sale['count'])
plt.ylabel('count', fontsize = 15)
plt.xlabel('positive_unit_sales', fontsize = 15)
plt.xticks(fontsize = 15)
plt.yticks(fontsize = 15)
plt.show()

store_count = pd.DataFrame()
store_count['count'] = train_sample['store_nbr'].value_counts().sort_index()

fig, ax = plt.subplots(figsize = (18, 3))
sns.barplot(x = store_count.index, y = store_count['count'], ax = ax)
ax.set_ylabel('count', fontsize = 15)
ax.set_xlabel('store_nbr',fontsize = 15)
ax.tick_params(labelsize=15)

item_count = pd.DataFrame()
item_count['count'] = train_sample['item_nbr'].value_counts().sort_index()
plt.plot(item_count.index)