I am running a 'for' loop whose output is a data frame with two columns, column 1 with columns names and column 2 with data. It can be seen below:
Next, I would take the transpose of this data like this:
In the next iteration again I would get the similar data(with 2 columns as the first table) for which I don't need columns data, just data should append to the data from the first iteration as seen:
CodePudding user response:
Try:
df = df.append(new_df, ignore_index=True)
CodePudding user response:
For your first question first set your index to you desired column names column, then transpose using T
:
df2=df.set_index('1').T
1 Column1 Column2 Column3 Column4 Column5
2 data_1_1 data_1_2 data_1_3 data_1_4 data_1_5