I've dataframe with unknown columns. I need to find duplicates in column which start with OEInterestTraceData and only if they are more than 1 in column. Also need to assign 1 new variable/flag if they are duplicate in row then 1 else 0.
W_Interest = loaddata1.loc[:, loaddata1.columns.str.contains('OEInterestTraceData')]
if len(W_Interest.columns) > 1:
if W_Interest[W_Interest.duplicated(keep=False)]:
W_Interest[['dummy']] = 1
else:
W_Interest[['dummy']] = 0
else:
W_Interest[['dummy']] = 0
right now it is giving me below error:
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Please help out if you have any better solutions.
