Space
Space

Reputation: 51

Convert pandas data frame (with multiple columns) to series

I'm trying to convert my dataframe which looks like:

             ds          y
0    1999-01-04   0.000000
1    1999-01-05   1.330603
2    1999-01-06   4.556447
3    1999-01-07   6.823689
4    1999-01-08   8.949833
...         ...        ...
5377 2020-05-18  34.497940

To a series that looks like

1999-01-04   0.000000
1999-01-05   1.330603
1999-01-06   4.556447
1999-01-07   6.823689
1999-01-08   8.949833
...         ...       
2020-05-18  34.497940

I have looked at: Convert pandas data frame to series (and many others) and I still cannot accomplish the task.

Would appreciate any help.

Upvotes: 0

Views: 118

Answers (1)

BENY
BENY

Reputation: 323396

We can do

s=df.set_index('ds').y

Upvotes: 3

Related Questions