image_output_11.png image_output_74.png image_output_82.png image_output_24.png image_output_46.png image_output_25.png text_plain_output_5.png image_output_77.png image_output_47.png text_plain_output_15.png image_output_78.png image_output_17.png image_output_30.png text_plain_output_9.png image_output_73.png image_output_72.png image_output_14.png image_output_59.png image_output_39.png image_output_28.png text_plain_output_20.png image_output_84.png image_output_81.png image_output_23.png image_output_34.png image_output_64.png text_plain_output_4.png text_plain_output_13.png image_output_13.png image_output_40.png image_output_5.png image_output_48.png image_output_68.png image_output_75.png text_plain_output_14.png image_output_18.png text_plain_output_29.png image_output_58.png image_output_21.png text_plain_output_27.png image_output_52.png text_plain_output_10.png image_output_60.png text_plain_output_6.png image_output_7.png image_output_62.png text_plain_output_24.png text_plain_output_21.png image_output_56.png image_output_31.png text_plain_output_25.png image_output_65.png image_output_20.png text_plain_output_18.png image_output_69.png image_output_32.png image_output_53.png text_plain_output_3.png image_output_4.png image_output_51.png text_plain_output_22.png image_output_83.png image_output_42.png image_output_35.png image_output_41.png image_output_57.png text_plain_output_7.png image_output_36.png image_output_8.png image_output_37.png image_output_66.png text_plain_output_16.png image_output_16.png image_output_70.png text_plain_output_8.png text_plain_output_26.png image_output_67.png image_output_27.png image_output_54.png image_output_6.png image_output_45.png image_output_63.png image_output_71.png image_output_80.png text_plain_output_23.png image_output_12.png text_plain_output_28.png image_output_22.png text_plain_output_2.png image_output_55.png application_vnd.jupyter.stderr_output_1.png image_output_3.png image_output_29.png image_output_44.png image_output_43.png text_plain_output_19.png image_output_2.png image_output_1.png image_output_10.png text_plain_output_17.png text_plain_output_11.png text_plain_output_12.png image_output_33.png image_output_50.png image_output_15.png image_output_49.png image_output_76.png image_output_9.png image_output_19.png image_output_79.png image_output_61.png image_output_38.png image_output_26.png
import matplotlib.pyplot as plt

import numpy as np # linear algebra

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

people = pd.read_csv('../input/people.csv', dtype={'people_id': np.str, 'activity_id': np.str, 'char_38': np.int32}, parse_dates=['date'])
act_train = pd.read_csv('../input/act_train.csv', dtype={'people_id': np.str, 'activity_id': np.str, 'otcome': np.int8}, parse_dates=['date'])
act_test = pd.read_csv('../input/act_test.csv', dtype={'people_id': np.str, 'activity_id': np.str, 'otcome': np.int8}, parse_dates=['date'])

act_train['date'].groupby(act_train.date.dt.date).count().plot(figsize=(10, 5), label='Train')
act_test['date'].groupby(act_test.date.dt.date).count().plot(figsize=(10, 5), label='Test')

positive_counts = pd.DataFrame({'positive_counts': act_train[act_train['outcome'] == 1].groupby('people_id', as_index=True).size()}).reset_index()
negative_counts = pd.DataFrame({'negative_counts': act_train[act_train['outcome'] == 0].groupby('people_id', as_index=True).size()}).reset_index()
hstry = positive_counts.merge(negative_counts, on='people_id', how='outer')
hstry['positive_counts'] = hstry['positive_counts'].fillna('0').astype(np.int64)
hstry['negative_counts'] = hstry['negative_counts'].fillna('0').astype(np.int64)
hstry['profit'] = hstry['positive_counts'] - hstry['negative_counts']

hstry.sort_values(by='positive_counts', ascending=False).head(10)