Comments posted to this topic are about the item Querying the Pandas DataFrame
Sorry to bump in but is there any reason that speaks against or for using either of these options over the other?
print(df.query('Grade >= 73'))
print(df[df['Grade'] >= 73])
I want to be the very best
Like no one ever was
To be honest, I'm not really sure if there is a performance difference. The query method tends to be simpler and easier to read for many folks, but I think it comes down to a matter of opinion and personal preference.
At one point in time, before Pandas 0.25, column names that contained spaces couldn't be used with the query method, so this might have been considered a disadvantage. We can now escape them by using backticks.
I did find this link from one of the Pandas developers talking about this very topic.
Viewing 3 posts - 1 through 2 (of 2 total)