You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a data frame that has a large number of columns that have positive numeric values except the last 4 columns. There are some rows with missing data, but in this dataset, they denote that by using a very large negative number. My plan was to use the query function to filter the rows to only those that have values greater than or equal to zero in every numeric column.
Feature Description
I wish the query function would let me do something like this df.query('* >= 0') the star * representing all columns. Better yet, would be if I could use star but subtract the columns to be excluded from that like df.query('* -state -county >= 0').
Alternative Solutions
What I am going to do is loop through the columns of the data frame and query on each one using a variable and exclude those non-numeric from my list. Like this:
column_list.remove('state')
column_list.remove('county')
for column in column_list:
df = df.query('@column >= 0')
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Do you have an idea how this would be implemented with the ast parser used to parse the query string? What if there's a column named *? Can it even parse it?
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
I have a data frame that has a large number of columns that have positive numeric values except the last 4 columns. There are some rows with missing data, but in this dataset, they denote that by using a very large negative number. My plan was to use the query function to filter the rows to only those that have values greater than or equal to zero in every numeric column.
Feature Description
I wish the query function would let me do something like this df.query('* >= 0') the star * representing all columns. Better yet, would be if I could use star but subtract the columns to be excluded from that like df.query('* -state -county >= 0').
Alternative Solutions
What I am going to do is loop through the columns of the data frame and query on each one using a variable and exclude those non-numeric from my list. Like this:
Additional Context
No response
The text was updated successfully, but these errors were encountered: