Currently my data frame looks something like this
A B C D
1 2 2 3
4 5 5 6
I want some thing like this
Insert_date Bulk_load
09-09-2022 [[A, B,C,D],
[1,2,2,3],
[4,5,5,6]]
10-09-2022 [[Q,Z,R,F], (This is an example for dataframe with new values.)
[1,2,2,3],
[4,5,5,6]]
Has any one tried to implement this before?
CodePudding user response:
Is this what you're looking for?
>>> [df.columns.tolist()] df.values.tolist()
[['A', 'B', 'C', 'D'], [1, 2, 2, 3], [4, 5, 5, 6]]
bulk_df = pd.DataFrame(columns=['Insert_date', 'Bulk_load']).set_index('Insert_date')
bulk_df.loc['09-09-2022', 'Bulk_load'] = [df.columns.tolist()] df.values.tolist()
print(df)
Output:
Bulk_load
Insert_date
09-09-2022 [[A, B, C, D], [1, 2, 2, 3], [4, 5, 5, 6]]