Home > Enterprise >  If a value in a dataframe column is less than 0, then set the row with that value to False?
If a value in a dataframe column is less than 0, then set the row with that value to False?

Time:01-05

I know that when a value in a column is empty, setting the row in which the empty value is located to False can be done using the following method: df_device_commission[['X']].notna().any(axis=1)

My question is: If a value in a dataframe column is less than 0, then set the row with that value to False

How should this be achieved ?

CodePudding user response:

As you mentioned lt which equal to <

df_device_commission[['X']].lt(0).any(axis=1)
#(df_device_commission[['X']]<0).any(axis=1)

CodePudding user response:

This simple line of code will solve your issue

df_device_commission[df_device_commission['X']<0] = False
  •  Tags:  
  • Related