-2

So,I have a data frame where I want to compare the values of one column with an integer to check the minima and replace it in the data frame. In R I did something like this: maxPriceRatio = 2.0; pmin(maxPriceRatio, (rdata[defined, "ABCD"]) It works

I want to do the same thing in Python. filteredDf.loc[:,'"ABCD'] = ? filteredDf["ABCD"] say, has 100 rows. I want to compare each entry with 2.0 and pick the minimum out for the two for the new data frame.

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
Abhinav Bhardwaj
  • 167
  • 1
  • 1
  • 8

1 Answers1

0

Use np.minimum

filteredDf.loc[:,"ABCD"] = np.minimum(filteredDf.loc[:,"ABCD"], 2.0)
RootTwo
  • 4,288
  • 1
  • 11
  • 15