Skip to content
Advertisement

Alternative to the pandas negation operator

I’m trying to use the pandas negation operator ~ in one of my jinja2 templates but I believe its conflicting with their special operator ~.

JavaScript

yields the following exception…

JavaScript

I could do the operation on the python side and pass another variable with the negated selection but what’s the method name equivalent that the ~ operator maps to that I could invoke in the template.

Advertisement

Answer

Looks like even more than the ~ operator choked, I couldn’t use the column slice operator either :, it would yield a SyntaxError: invalid syntax when the template compiled

However both the following worked identically using the tip from @piRSquared….

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement