【发布时间】:2021-12-11 11:24:53
【问题描述】:
我有一个名为 d0、d1、d2、...d9 的 10 个数据帧的列表。都有 3 列和 100 行。
d0.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 100 entries, 0 to 99
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 0 100 non-null float64
1 1 100 non-null float64
2 2 100 non-null float64
dtypes: float64(3)
memory usage: 2.5 KB
我想合并所有数据框,这样我就可以拥有 3 列和 1000 行,然后将其转换为数组。
s1=[d0,d1,d2,d3,d4,d5,d6,d7,d8,d9]
s2=pd.concat([s1])
以上代码报错:
TypeError: cannot concatenate object of type '<class 'list'>'; only Series and DataFrame objs are valid
type(s1)
list
我使用了pd.concat in pandas is giving a TypeError: cannot concatenate object of type '<class 'str'>'; only Series and DataFrame objs are valid 中建议的解决方案;但是,出现上述错误。
【问题讨论】:
标签: python pandas dataframe numpy types