I have the data in below format in an csv :-
However, the format in which I required is below :-
I have written below code, but somehow the groupby is not working for me.
def grouping():
df = pd.read_csv("final_data_6.csv")
df['n'] = df.apply(lambda x: (x['data'], x['Period']), axis=1)
df.groupby(['data','Period'])['n'].apply(list).reset_index()
df.to_csv("final_data_9.csv", encoding="utf-8", index=False)

