'TypeError when querying dataframe with field condition

I am trying to make the following query:

df7[df7['bath'] > 10]

But I am getting the following error:

TypeError: '>' not supported between instances of 'method' and 'int'

Here is an image of my environment with the dataframe and error.



Solution 1:[1]

df7[df7['bath'] > 10] is the correct command if your column name is "bath" and its dtype is float.

You could check the dtype of the columns in your dataframe (making sure it's not object or some other datatype) by printing df7.dtypes

You could also confirm the names of your columns by printing df7.columns to ensure that the column name is indeed "bath" and not " bath" or "bath " (note the extra spaces). It's hard to tell that from the attached screenshot.

Do update if it works for you, or if you run into more errors.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aravind G.