I need help with this code:
d={'Name': ['Mark', 'Lala', "Nina", 'Catherine', 'Izzy', 'Ozno', 'Kim'],
'Level' : ['A', 'B', 'C', 'D', 'E', 'D', 'D'],
'Seats' : [3000, 5000, 4000, 1000, 1000, 2600, 2400]}
df = pd.DataFrame(data = d)
I want to add a new column called "Level_corrected", this is a duplicate of df['Level'], but if df['Level'] = 'D' and df['Seats'] <2500, than the 'D' value in df['Level_corrected'] will become 'D-'.
The desired result is:
d={'Name': ['Mark', 'Lala', "Nina", 'Catherine', 'Izzy', 'Ozno', 'Kim'],
'Level' : ['A', 'B', 'C', 'D', 'E', 'D', 'D'],
'Seats' : [3000, 5000, 4000, 1000, 1000, 2600, 2400],
'Level_corrected': ['A', 'B', 'C', 'D-', 'E', 'D', 'D-']}
df = pd.DataFrame(data = d)
I've done several attempts (I didn't save the code ...), but it seems like the error is because of the different data types. The Level column is an 'object' and the Seats column is a float64.
Could someone please help me?
Many thanks!