I am working with pandas and a rather large excel document. My goal is to find and replace particular characters in a string and replace them with nothing, essentially removing the characters. The strings are in a particular column. Below you will see the code that I have created to find and replace, however python is not giving me an error message, and when I checked the saved file nothing has changed. What am I doing wrong?
import pandas as pd
df1 = pd.read_csv('2020.csv')
(df1.loc[(df1['SKU Code'].str.contains ('-DG'))])
dfDGremoved = (df1.loc[(df1['SKU Code'].str.contains('-DG'))].replace('-DG',''))
dfDGremoved.to_csv('2020DRAFT.csv')
df1['SKU Code'] = df1['SKU Code'].replace('-DG', ''). and then justdf1.to_csv('2020DRAFT.csv')(df1.loc[(df1['SKU Code'].str.contains ('-DG'))])doesn't have any effect.