I need to multiply the values of a column by 2.2 but only if the values are less than 30. Any help would be much appreciated
Here is what I tried. I know it is super wrong but I have no idea where to go with this. I am new to python, so forgive the really dumb question.
Values less than 30 are in kg and need to be recalculated into pounds.
df['Weight']=np.where(df['Weight'] > 30, df['Weight']*2.2)
Given this dataframe for example:
You can use
.loclike this:You can read more about selecting data here.
You can also use
DataFrame.where(notnumpy.where):Or
DataFrame.mask: