プログラム
from_list.py
#! /usr/bin/python
#
# from_list.py
#
# Jul/15/2024
# ------------------------------------------------------------------
import pandas as pd
keys = ['aa','bb','cc','dd']
data = [[1,2],[4,56],[9,83],[11,24]]
df0 = pd.DataFrame({
'aa': [1,2],
'bb': [4,56],
'cc': [9,83],
'dd': [11,24],
})
print(df0)
print()
df = pd.DataFrame({keys[i]: data[i] for i in range(len(keys))})
print(df)
# ------------------------------------------------------------------
実行結果
$ ./from_list.py
aa bb cc dd
0 1 4 9 11
1 2 56 83 24
aa bb cc dd
0 1 4 9 11
1 2 56 83 24