[英]TypeError: cannot concatenate object of type '<class 'yfinance.ticker.Options'>'; only Series and DataFrame objs are valid
[英]TypeError: cannot concatenate object of type '<class 'list'>'; only Series and DataFrame objs are valid
我有一個名為 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 中使用了pd.concat 中建議的解決方案給出了一個TypeError: cannot concatenate object of type '<class 'str'>'; 只有 Series 和 DataFrame 對象有效; 但是,得到了上述錯誤。
s1
已經是一個列表。 使用帶有 DataFrame 的列表列表執行您所做的稱為 pd.concat 的操作,這是熊貓不允許的。 你應該這樣做:
s2=pd.concat(s1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.