-
-
Save smram/d6ded3c9028272360eb65bcab564a18a to your computer and use it in GitHub Desktop.
# got to handle both escaped and literal | |
df.replace(to_replace=[r"\\t|\\n|\\r", "\t|\n|\r"], value=["",""], regex=True, inplace=<INPLACE>) |
Thank you very much. I tried so many tricks about it from stackoverflow, none of them worked, only your script works.
very helpful !
Thank you! I'll add a reference to this in the Stack Overflow answer LOL
Thanks a lot!
Thank you!!!
what values needs to be passed at 'inplace'
@hargurjeet inplace is a Boolean, True will replace in place, False will return a new value. https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.replace.html?highlight=replace#pandas.DataFrame.replace
This is great! It is becoming part of the standard data wrangling that I do!
can you break down this code or provide a reference? Thank you!
This also worked for me! And I had also tried many suggestions from StackOverflow that did not work. Thank you!
I got typeError: Cannot compare types 'ndarray(dtype=int64)' and 'str'
on one of the rows in the database table
with inplace=False worked like a charmed, with =True it didn't let me do the "to_CSV". anyway, problem solved!
Thanks! I originally tried using replace without regex, but that didn't seem to work. Maybe python was treating it as a string literal or something.