Sorting pandas dataframe with inf and NaN
I have a pandas dataframe that I would like to sort in descending column order.
Name count
AAAA -1.1
BBBB 0
CCCC -10
DDDD inf
EEEE 3
FFFF NaN
GGGG 30
I want to sort by, in descending order, and move the line inf
and NaN
up to the end.
df.sort('count',ascending = False,na_position="last")
pushes NaN
to the end. How to deal with inf
?
+3
source to share
2 answers