Pandas - Filtering None Values

前端 未结 3 1933
旧巷少年郎
旧巷少年郎 2020-12-13 08:39

I\'m using Pandas to explore some datasets. I have this dataframe:

I want to exclude any row that has a city value. So I\'ve tried:

new_df =         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-13 08:55

    I hope "where" can do what you expect

    new_df = new_df.where(new_df["city"], None) 
    

    And it is better use np.nan rather than None.

    For more details pandas.DataFrame.where

提交回复
热议问题