I have a dataframe like this
Data = pd.read_csv('info_com.csv')
df1 = pd.DataFrame(Data)
This DF has a column ‘Code’, that includes all product codes, and the DF pretty much includes all the information of said products. So, I have a list with the codes of interest, but in reality, I need two df, one with the rows of the “good codes” and one with the bad codes.
I tried doing some kind of sort, and a loop
ComDF1 = df1['Codes']
goodCodes = ['B0CD3589HR' ... 'B0CD726Q8T']
for i in range(len(ComDF1)):
if ComDF1[i] in goodCodes:
df1.iloc[i].append(dfWP)
else:
df1.iloc[i].append(dfNWP)
print(dfWP, dfNWP)
And expected two DF with all the info of every product, sorted by the existence or the absence of the column value in the list…
melgibsonuwu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1