I have a dataframe and I want to query based on a value within a column.
#Following code works:
{
df_18.query("fuel == 6")
}
#but, all the following query throws error:
{
df_18.query("fuel.contains('6')")
df_18.query("fuel.str.contains('6')")
}
Please let me know what is the problem. Also Python documentation does not speak much about what is supported inside query function and what not.
yes, you can, using python
engine:
In [36]: d
Out[36]:
fuel
0 92
1 95
2 16
3 06
In [37]: d.query("fuel.str.contains('6')", engine='python')
Out[37]:
fuel
2 16
3 06
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.