sum the minimum of the column when the column contains a negative value

Refresh

February 2019

Views

14 time

-1

I have a dataframe like this

idx    A         B     C      D
  1    0.01   0.01  0.03    0.01
  2   -0.01  -0.02  0.04   -0.01
  3    0.02  -0.03  0.02    0.05
  4    0.03   0.01  0.01    0.01

What I need to do is shifting all the series by their minimum value, when the series contains a negative value. I would very much like not to do this by either melting the dataframe or by loop over each column. Is there a way to do this with numpy.where or similar?

0 answers