This is the sample string value in a pandas df column :
'Had {0} {1} in {2}.format(num_of_persons,type_of_person,date)'
I want to extract the code part starting at '.format()' and input the values in the string where it would look something like this:
num_of_persons='20'
type_of_person ='patients'
date='2020-04'
text='Had {0} {1} in {2}'.format(num_of_persons,type_of_person,date)
I want to extract and output like this in the pandas df column :
'Had 20 patients in 2020-04'
I tried splitting the string at '.' but unsure how to convert the second half into code and not the string that will execute.
Any help is appreciated
num_of_personsetc refer to local variables? are there more than three?