Это то, что вы ищете?
import pandas as pd
d = ({
'column_a' : ['North Europe','East Europe','West Europe'],
'average_1' : [143, 100.755, 175.1],
'average_2' : [297.9, 171.21, 227.55 ],
'column_b' : [79.265, 60.8078, 76.468],
})
data_set = pd.DataFrame(d)
column_a = data_set['column_a']
column_b = data_set['column_b']
average_1 = data_set['average_1']
average_2 = data_set['average_2']
df = pd.DataFrame([column_a, column_b, average_1, average_2])
df = df.T
print(df)
column_a column_b average_1 average_2
0 North Europe 79.265 143 297.9
1 East Europe 60.8078 100.755 171.21
2 West Europe 76.468 175.1 227.55
Или вы можете использовать pd.concat
вместо:
import pandas as pd
d = ({
'column_a' : ['North Europe','East Europe','West Europe'],
'column_b' : [79.265, 60.8078, 76.468],
})
data_set1 = pd.DataFrame(d)
d = ({
'average_1' : [143, 100.755, 175.1],
'average_2' : [297.9, 171.21, 227.55],
})
data_set2 = pd.DataFrame(d)
column_a = data_set1['column_a']
column_b = data_set1['column_b']
average_1 = data_set2['average_1']
average_2 = data_set2['average_2']
df = pd.concat([column_a, column_b, average_1, average_2], axis = 1)
print(df)
column_a column_b average_1 average_2
0 North Europe 79.265 143 297.9
1 East Europe 60.8078 100.755 171.21
2 West Europe 76.468 175.1 227.55