0

I am trying to remove asterisks from strings in a pandas dataframe column efficiently.

I have tried the using replace function alone, but it doesn't change the values in my dataframe. If I use the following code, I get the desired effect:

dfc['Trimmed Peptide'] = dfc['Trimmed Peptide'].str.replace('*', '', regex=False)

Unfortunately, I also get this warning: "A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead."

When I try

dfc.loc['Trimmed Peptide'] = ...

I still get the error. How can I avoid copying the array?

nod11
  • 11
  • 2
  • The error is not from this code, it's from code that creates `dfc`. I suggest doing some reading: https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas/53954986#53954986 – cs95 Jun 25 '19 at 18:36
  • Possible duplicate of https://stackoverflow.com/q/20625582/4909087 – cs95 Jun 25 '19 at 18:37
  • https://stackoverflow.com/questions/56759142/pandas-replace-the-asterisk-sign-from-two-columns-in-one-go#comment100076103_56759142 – harvpan Jun 25 '19 at 18:38

0 Answers0