我想合并系列的数据。但结果是,这些数据被分为三个。如何将这些数据合并为一个? (python3 jupyter notebook)
fp_price = pd.Series(data)
keep = []
for i in fp_price:
fp_price_merge = i
keep.append(fp_price_merge)
print(keep)
结果
[487832.87560916983, 488448.86992150272, 490797.3482372716,
490127.78920212726, 490493.25684214354, 490632.19034193602]
[481897.10423319356, 482361.70278453565, 482144.11241496605,
481998.03776126896, 482209.0344832759, 482318.84407537803]
[483650.51656619791, 483357.08254157269, 483476.66114698362,
483627.19449776667, 483503.16349747358, 483547.58143689478]
答案 0 :(得分:1)
使用sum
展平列表:
sum(fp_price, [])
In [11]: s = pd.Series([[1, 2], [3]])
In [12]: sum(s, [])
Out[12]: [1, 2, 3]
答案 1 :(得分:0)
这将打印出list
的值。
l=fp_price.values.tolist()
import functools
functools.reduce(lambda x,y: x+y,l)
答案 2 :(得分:0)
您可以使用“concat”功能。如果您对处理指数有特定要求,则有很多变化。
代码:
fp_price = pd.Series(data)
keep = []
for i in fp_price:
fp_price_merge = i
keep.append(fp_price_merge)
result=pd.concat(keep)
print(result)