USING LIKE inside pandas.query()

If you have to use df.query(), the correct syntax is:

df.query('column_name.str.contains("abc")', engine="python")

You can easily combine this with other conditions:

df.query('column_a.str.contains("abc") or column_b.str.contains("xyz") and column_c>100', engine="python")

It is not a full equivalent of SQL Like, however, but can be useful nevertheless.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)