且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将 Pandas 系列转换为 DataFrame

更新时间:2021-09-07 18:28:27

您可以使用 DataFrame 构造函数将它们作为 dict 中的参数传递,而不是创建 2 个临时 dfs:

Rather than create 2 temporary dfs you can just pass these as params within a dict using the DataFrame constructor:

pd.DataFrame({'email':sf.index, 'list':sf.values})

构建 df 的方法有很多,参见 文档

There are lots of ways to construct a df, see the docs