My dataset is in this form:
df = pd.DataFrame({'ID': [1,2,3,4],
'Type': ['A', 'B', 'B', 'B'],
'Value': [100, 200, 201, 120]})
I want to update the dataframe in the following way:
df = pd.DataFrame({'ID': [1,2,3,4],
'Type': ['A', 'B1', 'B2', 'B3'],
'Value': [100, 200, 201, 120]})
The code I was trying was:
df[df['Type'] == 'B', df['Value'] == 200] = 'B1'
But I'm getting error:
ValueError: Cannot reindex from a duplicate axis
Can someone please help me solve the problem?
Thanks!