Python Pandas: DataFrame filter negative values

前端 未结 4 595
独厮守ぢ
独厮守ぢ 2021-01-31 05:30

I was wondering how I can remove all indexes that containing negative values inside their column. I am using Pandas DataFrames.

Documentation Pandas DataFr

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-31 06:25

    To use and statements inside a data-frame you just have to use a single & character and separate each condition with parenthesis.

    For example:

    data = data[(data['col1']>0) & (data['valuecol2']>0) & (data['valuecol3']>0)]
    

提交回复
热议问题