How to get the max/min value in Pandas DataFrame when nan value in it

前端 未结 6 894
萌比男神i
萌比男神i 2021-01-01 19:07

Since one column of my pandas dataframe has nan value, so when I want to get the max value of that column, it just return error.

>>> d         


        
6条回答
  •  一整个雨季
    2021-01-01 19:58

    Dataframe aggregate function.agg() will automatically ignore NaN value. df.agg({'income':'max'})

    Besides, it can also be use together with .groupby

    df.groupby('column').agg({'income':['max','mean']})

提交回复
热议问题