I have data Frame like below
And I want merge "Transaction Particulars" index of 24,25 and 26 on index of 25 , same as merge Transaction Particulars index of 28,29 and 30 on index of 29 And this merge based on Tran Date if Above and below value of Tran Date is Nan then merge all this three index on Tran Date value index
i try with
tm['originalIdx'] = tm.apply(lambda x:x.name if x['Tran Date']!='' else None, axis=1).ffill()
tm = pd.merge(tm.drop('Transaction Particulars', axis=1),
pd.DataFrame(tm.groupby(['originalIdx'])['Transaction Particulars'].apply(lambda x: " ".join(x))),
left_index=True, right_index=True, how='left')
