If you are working with a pandas DataFrame and you need to remove some faulty characters that should not exist in one of your columns, then this post is for you.
Let’s create a DataFrame manually. I contains some bad characters in the firstname column, but we will clean that up.
import pandas as pd # import the pandas library into Python data = {'firstname': ['Bo/b', '/Sally', '..Suzie', 'Rowan'], 'amount': [12, 67, 33, 41], 'color': ['Blue','Pink','Red','Green']} df = pd.DataFrame(data) df
Here is where we are starting from. This is a screenshot in Jupyter Notebook.