Reputation: 45
I have the following Dataframe and I would like to filter typePath on value : \Universe
id name technicalName dataType path typePath
0 c64041 Active Client Active Client Property \Sales\Client\Active Client \Universe\Concept\BusinessTerm
1 c64042 Active Customer Active Customer Property \Sales\Client\Active Customer \Universe
However when I do it like this :
df2=df_Glossary.query("typePath == '\Universe'")
df2
I have the following error message :
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 13-14: truncated \UXXXXXXXX escape
Someone has the solution to able me to filter on the value I have indicated
Upvotes: 0
Views: 30
Reputation: 34086
You need to add r
to convert the normal string to raw string. Also, you need to escape \U
with \\U
:
In [481]: df_Glossary.query(r'typePath == "\\Universe"')
Out[481]:
id name technicalName dataType path typePath
1 c64042 Active Customer Active Customer Property \Sales\Client\Active Customer \Universe
OR as pere @JANO's comment:
df_Glossary.query(r'typePath == r"\Universe"')
Upvotes: 2