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
Starting with Pandas v. 0.25, it is possible to refer to columns with names containing spaces if you enclose the column name in backticks within the query.
Using Pandas 0.25.2:
>>> df = pd.DataFrame({'a a': [1, 0], 'b b': [1, 1]})
>>> df
a a b b
0 1 1
1 0 1
>>> df.query('`a a`==`b b`')
a a b b
0 1 1
From the API docs: https://pandas.pydata.org/pandas-docs/version/0.25/reference/api/pandas.DataFrame.query.html
In your case, the usage would be:
dfResult.query('`Column A` in @ExcludeData')