pandas: filter rows of DataFrame with operator chaining

前端 未结 14 2366
悲哀的现实
悲哀的现实 2020-11-22 16:46

Most operations in pandas can be accomplished with operator chaining (groupby, aggregate, apply, etc), but the only way I

14条回答
  •  长情又很酷
    2020-11-22 17:29

    This is unappealing as it requires I assign df to a variable before being able to filter on its values.

    df[df["column_name"] != 5].groupby("other_column_name")
    

    seems to work: you can nest the [] operator as well. Maybe they added it since you asked the question.

提交回复
热议问题