I have dataframe with many rows. I want to use pd.replace to replace values in entire columns.
import pandas as pd
import re
list = ['MD 15241', 'MD', 'TD', 'TD 15487']
a = pd.DataFrame(list)
b = a.copy()
b.replace(r'[A-Z]{2}', 'USA', inplace = True)
b
output
0
0 MD 15241
1 MD
2 TD
3 TD 15487
I tried r'MD' or r'TD' , it works.
Pandas