python - USING LIKE inside pandas.query() -


i have been using pandas more 3 months , have fair idea dataframes accessing , querying etc.

i have got requirement wherein wanted query dataframe using keyword (like similar sql) in pandas.query().

i.e: trying execute pandas.query("column_name 'abc%'") command failing.

i know alternative approach use str.contains("abc%") doesn't meet our requirement.

we wanted execute inside pandas.query(). how can so?

super late post, comes across it. can use boolean indexing making search criteria based on string method check str.contains.

example:

dataframe[dataframe.summary.str.contains('windows failed login', case=false)] 

in code above, snippet inside brackets refers summary column of dataframe , uses .str.contains method search 'windows failed login' within every value of series. case sensitive can set true or false. return boolean index used return dataframe looking for. can use .fillna() in brackets if run nan errors.

hope helps!


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -