【发布时间】:2017-11-27 07:28:06
【问题描述】:
我用这段代码创建了一个字典:
dat[r["author_name"]] = (r["num_deletions"], r["num_insertions"],
r["num_lines_changed"], r["num_files_changed"], r["author_date"])
然后我想用这些字典创建一个带有列的熊猫
author_name | num_deletions | num_insertions | num_lines_changed |num_files changed | author_date
我试过这个:
df = pd.DataFrame(list(dat.iteritems()),
columns=['author_name',"num_deletions", "num_insertions", "num_lines_changed",
"num_files_changed", "author_date"])
但它不起作用,因为它将字典的键和元组读取为仅两列而不是六列。那么我怎样才能把元组中的五个条目中的每一个都分成自己的列
【问题讨论】:
标签: python pandas dictionary tuples