I have this sample code below that turns a Python list of lists into a pandas DataFrame, but I need to DataFrame orientation to be inversed, any idea how to achieve this?
import numpy as np
import pandas as pd
from IPython.display import display, HTML
i = np.zeros(10)
i.fill(40)
j = np.zeros(10)
j.fill(60)
df = pd.DataFrame([i, j])
display(df)
The output of this is a structure like this:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 |
| 1 | 60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 |
But, what I want is to get a structure like this, how can I turn a list of lists into such format?
| 0 | 1 |
|---|---|
| 40 | 60 |
| 40 | 60 |
| 40 | 60 |
| 40 | 60 |
| 40 | 60 |
| 40 | 60 |
| 40 | 60 |
| 40 | 60 |
| 40 | 60 |
df.T