This question has reference to this SO thread. For the sake of newness, I am providing the dataframe again.
ID Static_Text Params
1 Today, {0} is quite Sunny. Tomorrow, {1} 1-10-2020
may be little {2}
1 Today, {0} is quite Sunny. Tomorrow, {1} 2-10-2020
may be little {2}
1 Today, {0} is quite Sunny. Tomorrow, {1} Cloudy
may be little {2}
2 Let's have a coffee break near {0}, if I Balcony
don't get any SO reply by {1}
2 Let's have a coffee break near {0}, if I 30
don't get any SO reply by {1} mins
And this is what I want as a final Dataframe:
ID Final Text
1 Today, 1-10-2020 is quite Sunny. Tomorrow, 2-10-2020
may be little Cloudy
2 Let's have a coffee break near Balcony, if I
don't get any SO reply by 30 mins
One of the approach I am following is as follows:
df = df.groupby(['ID','Static_text']).['Params'].agg(list).reset_index()
df['Final Text'] = df.apply(lambda x : x['Static text'].format(','.join(x['Params'])),axis=1)
But the above method is throwing the following error:
IndexError: tuple index out of range
What I am missing here? I have figured out that some tricks need to be there in lambda x: part mayby.
For a sake of simplicity, lets assume that we have all the dates in string.