text_html_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train = pd.read_csv('../input/tabular-playground-series-mar-2022/train.csv')
test = pd.read_csv('../input/tabular-playground-series-mar-2022/test.csv')

train = train.set_index('row_id')
test = test.set_index('row_id')

train.time = pd.to_datetime(train.time)
test.time = pd.to_datetime(test.time)

x_unique = train.x.unique()
y_unique = train.y.unique()
d_unique = train.direction.unique()

train_min_time = train.time.min()
train_max_time = train.time.max()
test_min_time = test.time.min()
test_max_time = test.time.max()

congestion_mean = train.congestion.mean()

x_group_mean = train.groupby('x').congestion.mean()
y_group_mean = train.groupby('y').congestion.mean()
d_group_mean = train.groupby('direction').congestion.mean()
print(f'x_group_mean:\r\n {x_group_mean}\r\n')
print(f'y_group_mean:\r\n {y_group_mean}\r\n')
print(f'd_group_mean:\r\n {d_group_mean}\r\n')
plt.subplot(3, 1, 1)
plt.bar(x_group_mean.index, x_group_mean)
plt.xlabel('x')
plt.ylabel('mean')
plt.xticks(x_group_mean.index)
plt.subplot(3, 1, 2)
plt.bar(y_group_mean.index, y_group_mean)
plt.xlabel('y')
plt.ylabel('mean')
plt.xticks(y_group_mean.index)
plt.subplot(3, 1, 3)
plt.bar(d_group_mean.index, d_group_mean)
plt.xlabel('direction')
plt.ylabel('mean')
plt.xticks(d_group_mean.index)
plt.show()