python dataframe query with spaces in column name

前端 未结 3 680
庸人自扰
庸人自扰 2021-01-29 02:22

I want to filter dataframe using query

ExcludeData= [1,3,4,5]
dfResult.query(\'Column A in @ExcludeData\')

How do I use Column A in query with

3条回答
  •  清歌不尽
    2021-01-29 02:44

    I wouldn't use query function. I would use the square bracket notation:

    dfResult = dfResult[dfResult['Column A'].isin(ExcludeData)]
    

提交回复
热议问题