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

df_first = pd.read_csv('/kaggle/input/retail-case-study-data/prod_cat_info.csv')

df_second = pd.read_csv('/kaggle/input/retail-case-study-data/Customer.csv')

df_third = pd.read_csv('/kaggle/input/retail-case-study-data/Transactions.csv')

md = df_third.groupby(['cust_id', 'prod_cat_code', 'prod_subcat_code'])['transaction_id'].count().to_dict()

df_combined = pd.merge(df_third, df_first, left_on=['prod_cat_code', 'prod_subcat_code'], right_on=['prod_cat_code', 'prod_sub_cat_code'], how='left')

grp_df = df_combined.groupby(['cust_id', 'prod_cat', 'prod_subcat', 'tran_date'])['tran_date', 'prod_subcat'].count()

df_third.columns

df_third_part = df_third[df_third.Rate > 0].reset_index()
df_combined = pd.merge(df_third_part, df_first, left_on=['prod_cat_code', 'prod_subcat_code'], right_on=['prod_cat_code', 'prod_sub_cat_code'], how='left')

cust_id = 272098
tran_date = '13-05-2013'
df_combined[(df_combined['cust_id'] == cust_id) & (df_combined['tran_date'] == tran_date)]