image_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
train = pd.read_csv('../input/tabular-playground-series-sep-2022/train.csv')
test = pd.read_csv('../input/tabular-playground-series-sep-2022/test.csv')
ss = pd.read_csv('../input/tabular-playground-series-sep-2022/sample_submission.csv')

cols = ['country', 'store', 'product']

cnt_val = pd.unique(train['country'])
str_val = pd.unique(train['store'])
prod_val = pd.unique(train['product'])
data = np.empty(shape=48, dtype='object')
i = 0
for x in cnt_val:
    for y in str_val:
        for z in prod_val:
            data[i] = train[(train['country'] == x) & (train['store'] == y) & (train['product'] == z)]
            i += 1

colors=['r','g','b','c','m','y']
fig=plt.figure(figsize=(20,500))
i=0
j=-1
days=[i for i in range(data[0].shape[0])]
for x in cnt_val:
    j+=1
    for y in str_val:
        for z in prod_val:
            ax=fig.add_subplot(len(cnt_val)*len(str_val)*len(prod_val),1,i+1)
            ax.set_title(x+', '+y+', '+z)
            ax.set_ylabel('num_sold')
            ax.plot(days,data[i]['num_sold'],color=colors[j])
            i+=1
plt.show()

i = 0
j = -1
s = [i for i in range(24, 48)]
fig = plt.figure(figsize=(25, 90))
for x in cnt_val:
    j += 1
    for y in str_val:
        for z in prod_val:
            ax = fig.add_subplot(12, 4, i + 1)
            ax.set_title(x + ', ' + y + ', ' + z)
            ax.set_ylabel('number_of_samples')
            if i not in s:
                ax.hist(data[i]['num_sold'], bins=50, color=colors[j], ec='black')
            else:
                ax.hist(data[i]['num_sold'].iloc[1100:], bins=50, color=colors[j], ec='black')
            i += 1
plt.show()