image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

INPUT_DIR = '../input/'
TRAIN_FILE = 'train.json'
TEST_FILE = 'test.json'
train_df = pd.read_json(INPUT_DIR + TRAIN_FILE)
test_df = pd.read_json(INPUT_DIR + TEST_FILE)
all_df = pd.concat((train_df, test_df), axis=0)
all_df['train'] = all_df['interest_level'].notnull()
all_df['test'] = all_df['interest_level'].isnull()
n_train = train_df.shape[0]
n_test = test_df.shape[0]
n_total = n_train + n_test
n_train_pct = n_train / n_total * 100.0
n_test_pct = n_test / n_total * 100.0

# How does the train / test split depend on the creation date?
all_agg_df = all_df.copy()
all_agg_df = all_agg_df.set_index('created', drop=True)
all_agg_df = all_agg_df.groupby('train').resample('1D').size().transpose()

fig, ax = plt.subplots(1,1, figsize=(18,10))
ax = all_agg_df.plot.bar(ax=ax, stacked=True)
ax.set_xticklabels(all_agg_df.index.strftime('%a %b %d'))
ax.set_title('All listings creation date and train/test split');

all_agg_df.head()

all_agg_df = all_df.copy()
all_agg_df['dayofweek'] = all_df['created'].dt.dayofweek
all_agg_df = all_agg_df.groupby('dayofweek').size()
all_agg_df.plot.bar(title='All row creation by day of week')