I have this data frame:
import pandas as pd
columns = ['ID','Data']
data = [['26A20',123],
['12A20',123],
['23A20',123]]
df = pd.DataFrame.from_records(data=data, columns=columns)
>>df
ID Data
0 26A20 123
1 12A20 123
2 23A20 123
And a simple task, to remove the A:s from ID when ID starts with 26 or 23:
df.loc[df['ID'].str.startswith(('23','26'))]['ID'] = df['ID'].str.replace('A','')
SettingWithCopyWarning: 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
And nothing Changes:
>>df
ID Data
0 26A20 123
1 12A20 123
2 23A20 123
Im using loc, what am I doing wrong?