image_output_1.png
from random import sample

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

airvisit = pd.read_csv('../input/air_visit_data.csv')

ids = airvisit.air_store_id.unique()
mindate = airvisit.visit_date.min()
maxdate = airvisit.visit_date.max()
skeleton = pd.DataFrame({})
dates = pd.date_range(mindate, maxdate, freq='D')
skeleton = pd.DataFrame({})
skeleton['visit_date'] = np.ravel([pd.to_datetime(x) for x in dates] * len(ids))
skeleton['air_store_id'] = np.ravel([[x] * len(dates) for x in ids])
groupcols = ['visit_date', 'air_store_id']
subcols = ['visit_date', 'air_store_id', 'visitors']
airvisit['visit_date'] = pd.to_datetime(airvisit['visit_date'])
series = pd.merge(skeleton, airvisit[subcols], on=groupcols, how='left')

from random import sample
samp = sample(list(ids), 10)
plt.figure(figsize=(18, 3.5 * len(samp)))
for idx, i in enumerate(samp):
    plt.subplot(len(samp), 1, idx + 1)
    sub = series[series.air_store_id == i].reset_index()
    plt.plot(sub.visitors)
    plt.title(i)