to_latex: Incorrect Encoding for Strings (with Backslashes)

Viewed 134

I have a DataFrame df that looks like this:

|      A      | B | ... |
-------------------------
|    a\b\c    | 2 | ... |
|    p\y\c    | 9 | ... |
|    a\d\x    | 4 | ... |

Calling to_latex on this DataFrame returns strings like a\textbackslashb\textbackslashc, what obviously is an error for LaTeX.

Are there any options or common encoding strategies for this?

Edit: Using escape=False returns a\b\c what is also an error for LaTeX.

1 Answers

Since this seemed to be a bug, I've created an issue and a pull request that got merged into the master and will be part of the next release (0.23.0).

It can handle now cases like a\b\c, the special chars ^ and ~ were also affected.

For more information see here.

Related