I have a pandas column as such (example):
1 France
2 France
3 Germany
4 Germany
5 Germany
6 Spain
7 Spain
8 Spain
175 France.2
176 France.2
177 Germany.2
178 Germany.2
179 Germany.2
180 UK.1
181 UK.1
182 UK.1
183 Italy.2
184 Italy.2
185 Italy.2
This would be my index and df[0].
I am trying to locate the ".1" and ".2" up to ".4". and remove them.
rename_rows = ['.1', '.2', '.3', '.4']
for row in df[0]:
for r in rename_rows:
if r in row:
df[0] = df[0].replace(r, '')
Nothing happens when this occurs.
If get down to the last loop "if r in row:" and I say print('True') it completes correctly. I've also tried replacing the df[0] = df[0].replace(r, '') to instead be df[0] = df[0].replace(row, '') and it successfully deletes the enter country name. However, I just want to delete the ".1" portion.
Any thoughts on why it won't delete that portion only?