I have a large dataframe of transactions which I want to break into two smaller dataframes based on a certain column ("Type"). If "Type" is "S" then add that entire row to the "cust_sell" dataframe, and if "Type" is "P" to the "cust_buy" dataframe. I am using a for loop, but this is only adding the index value to the dataframe. Any help is appreciated!
from win32com.shell import shell, shellcon
import pandas as pd
filename = (shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, None, 0)) + '\MSRB T-1_test.xlsx'
wb = pd.read_excel(filename, sheet_name='T1-20062017', index_col=0, header=0)
cust_buy = []
cust_sell = []
# Create a list of customer buys and sells separately
for i in wb.index:
if wb['Type'][i] == 'S':
cust_sell.append([i])
elif wb['Type'][i] == 'P':
cust_buy.append([i])