Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def plot_pivot_table(pivot_table):
- plt.figure(figsize=(14, 11))
- sns.heatmap(pivot_table, cmap="YlGnBu", annot=True,
- fmt='.3g', annot_kws={"size": 14, "fontsize": 14})
- plt.xticks(fontsize=15)
- plt.yticks(rotation=0, fontsize=15)
- plt.xlabel('Bucket', size=18)
- plt.ylabel('Hour', fontsize=18)
- plt.title('Gender analysis per bucket and hour', fontsize=20)
- plt.show()
- negative = transactions[transactions.amount<0].amount
- transactions['amount_bucket'] = pd.cut(negative, 5, labels=['Very High', 'High', 'Middle', 'Low', 'Very Low'])
- transactions
- transactions['amount_bucket'] = transactions['amount_bucket'].cat.add_categories('Income').fillna('Income')
- transactions['tr_hour'] = transactions['tr_datetime'].apply(lambda x: x.split()[1].split(':')[0])
- tp = transactions.pivot_table(['gender'], index=['tr_hour'], columns=['amount_bucket'])
- plot_pivot_table(tp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement