given a column of strings in a dataframe, the following code transforms them into integers. What I want to do is to just leave the string part without the dot, and whenever the cell contains a number in string form, I would like to change it to a string called 'number'. Just to be clear, the cells in this column have the following values:
'a. 12','b. 75','23', 'c/a 34', '85', 'a 32', 'b 345'
and I want to replace the cell values in this column with the following:
'a', 'b', 'number', 'c/a', 'number', 'a' , 'b'
How do I do that?
l2=['a. 12','b. 75','23', 'c/a 34', '85', 'a 32', 'b 345']
d = {'col1': []}
df = pd.DataFrame(data=d)
df['col1']=l2
df['col1'] = df['col1'].str.replace(r'\D', '').astype(str)
print(df)