Search code examples
pythonpandasdataframestartswith

my expresion for using the like 'XXX%' to express startswith isn't accepted by .query() of pandas


This is the expression that I want to pass to the function .query() of pandas external_identifier LIKE '16%'and act_rea in ['None'] But it brings this error: SyntaxError: invalid syntax


Solution

  • I get the issue in fact I can't use statswith with the expression of like and % The right expression is :

    pandas.query('external_identifier.str.startswith("16") and act_rea in ["None"] ')