【发布时间】:2019-11-28 17:58:07
【问题描述】:
我在我的数据集上使用statsmodels.api。我有一个熊猫系列的清单。熊猫系列有键值对。键是列的名称,值包含数据。但是,我有一个重复键(列名)的系列列表。我想将熊猫系列列表中的所有值保存到单个数据框中,其中列名是熊猫系列的键。列表中的所有系列都具有相同的键。我想将它们保存为单个数据框,以便可以将数据框导出为 CSV。知道如何将键保存为 df 的列名,然后让值填充其余信息。
列表中的每个系列都返回如下内容:
index 0 of the list: <class 'pandas.core.series.Series'>
height 23
weight 10
size 45
amount 9
index 1 of the list: <class 'pandas.core.series.Series'>
height 11
weight 99
size 25
amount 410
index 2 of the list: <class 'pandas.core.series.Series'>
height 3
weight 0
size 115
amount 92
我希望能够读取数据框,以便将这些值保存为以下内容:
DataFrame:
height weight size amount
23 10 45 9
11 11 25 410
3 3 115 92
【问题讨论】:
-
检查 pd.concat(l)
标签: python-3.x pandas dataframe statsmodels