Skip to content

Instantly share code, notes, and snippets.

@greister
Forked from smram/pandas_newline_strip.txt
Created October 14, 2019 04:54
Show Gist options
  • Save greister/d29c1bf17422e828c334d49ba15223f7 to your computer and use it in GitHub Desktop.
Save greister/d29c1bf17422e828c334d49ba15223f7 to your computer and use it in GitHub Desktop.
[pandas] replace newlines,tabs,carriage returns in fields
# got to handle both escaped and literal
df.replace(to_replace=[r"\\t|\\n|\\r", "\t|\n|\r"], value=["",""], regex=True, inplace=<INPLACE>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment