简体   繁体   English

append 系列在一个for循环 python

[英]append series in a for loop python

How can I append the pd.series output in a loop如何在循环中使用 append pd.series output

Input输入

for hours in fun(data, 24*10):
    model.fit(hours)
    df['output'] = pd.Series(model.predict(hours))

I want something like this我想要这样的东西

lst=[]

for hours in fun(data, 24*10):
    model.fit(hours)
    x = pd.Series(model.predict(hours))
    lst.append(x)

df['output'] = pd.DataFrame(lst)

pd.concat should work: pd.concat 应该可以工作:

lst=[]

for hours in fun(data, 24*10):
    model.fit(hours)
    x = pd.Series(model.predict(hours))
    lst.append(x)

df['output'] = pd.concat(lst, axis=0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM