Skip to content
Advertisement

Python pandas trying to get Cummin but get a zero value

I want to use cummin but it doesnt work, It shows zero, cummax work well.

my code:

JavaScript

original df:

JavaScript

my result :

JavaScript

Advertisement

Answer

It is expected, because after shift first value is 0, so after cummin is here always 0 (until negative value):

JavaScript

Remove fill_value=0 for NaN instead 0 for first value in Series.shift, last if necessary replace first missing value by Series.fillna:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement