0

I have a condition like this:

!(log(RevolvingUtilizationOfUnsecuredLines) > 3)

I want to assign all values in the Dataseries based on this condition.

Something like:

df.loc[np.log(df.RevolvingUtilizationOfUnsecuredLines) > 3, 'WeirdRevolvingUtilization'] = 0

I can't seem to find anything using custom functions like a Log or anything, any ideas?

Rodney Nogueira
  • 665
  • 1
  • 6
  • 15
  • 1
    It looks like dupe [link](https://stackoverflow.com/q/21608228/2901002) – jezrael Feb 07 '18 at 15:04
  • Both Wen's and your own answers are good. But if either are too slow for you, you should try and vectorise your calcs in underlying numpy. Just use pandas to build results table. – jpp Feb 07 '18 at 15:08

1 Answers1

0

Well it seems it was simple:

df.loc[np.log(df.RevolvingUtilizationOfUnsecuredLines) > 3, 'WeirdRevolvingUtilization'] = 0

I still don't know if this is the best solution.

Rodney Nogueira
  • 665
  • 1
  • 6
  • 15