bigsleep
bigsleep

Reputation: 327

pandas merge timeseries, concat/append/...?

I start out with a timeseries and use a loop to produce new timeseries. I would like to merge the existing series with the new ones subsequently in every loop, while preserving their (different) indices. I tried concat, but somehow I cannot add another series after the first one...

orig = pd.Series(data, index=index)
for i in list:
    new = pd.Series(...)
    orig = pd.concat([orig, new], axis=1)

Thanks for your help!

Upvotes: 3

Views: 4646

Answers (2)

Michael WS
Michael WS

Reputation: 2617

I do something like this all the time but I use append like this:

orig = pd.Series(data, index=index)
for i in list:
    new = pd.Series(...)
    orig = orig.append(new)

Can you verify that the index is unique?

http://pandas.sourceforge.net/merging.html#concatenating-using-append

Can you paste the traceback? I would be happy to debug it for you.

Upvotes: 1

eumiro
eumiro

Reputation: 213075

pd.concat takes a list of Series:

orig = pd.concat([pd.Series(...) for i in li], axis=1)

(renamed your list to li)

Upvotes: 6

Related Questions