From dcd4cccd3ad4f3efd7f54f84329adff1757ca8fa Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Fri, 26 Apr 2024 09:40:21 -0700 Subject: [PATCH] Use raw strings with escape sequences --- doc/user_guide/encodings/index.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/user_guide/encodings/index.rst b/doc/user_guide/encodings/index.rst index 62bcc51a8..264bacc02 100644 --- a/doc/user_guide/encodings/index.rst +++ b/doc/user_guide/encodings/index.rst @@ -280,9 +280,9 @@ in some data structures. The recommended thing to do when you have special characters in a column name is to rename your columns. For example, in pandas you could replace ``:`` with ``_`` -via ``df.rename(columns = lambda x: x.replace(':', '_'))``. +via ``df.rename(columns=lambda x: x.replace(':', '_'))``. If you don't want to rename your columns -you will need to escape the special characters using a backslash: +you will need to escape the special characters using a raw string with a backslash: .. altair-plot:: @@ -295,11 +295,11 @@ you will need to escape the special characters using a backslash: }) alt.Chart(source).mark_bar().encode( - x='col\:colon', + x=r'col\:colon', # Remove the backslash in the title - y=alt.Y('col\.period').title('col.period'), + y=alt.Y(r'col\.period').title('col.period'), # Specify the data type - color='col\[brackets\]:N', + color=r'col\[brackets\]:N', ) As can be seen above,