I have some columns that follow the pattern 'abc.def' and I'm trying to change it to 'abcDef' with a function. I can do it with df.rename(columns={'abc.def': 'abcDef'}, inplace = True) but looking for a more generic approach that can be applied to different data frames. I did it for the simple string and I do not know how to apply it to the column names. I have tried to get column names to the list and append the function to the list but that did not work either.
My df is:
import pandas as pd
import re
data = {'end.date': ['01/10/2020 15:23', '01/10/2020 16:31', '01/10/2020 16:20', '01/10/2020 11:00'],
'start.date': ['01/10/2020 13:38', '01/10/2020 14:49', '01/10/2020 14:30','01/10/2020 14:30']
}
df = pd.DataFrame(data, columns = ['end.Date','start.date'])
# below is my go at the text.
text = 'abs.d'
splitFilter = re.compile('([.!?]\s*)')
splitColumnName = splitFilter.split(text)
print(splitColumnName)
final = ''.join([i.capitalize() for i in splitColumnName])
final = final.replace('.', '')
print(final)