HRDSL
HRDSL

Reputation: 761

Converting pandas dataframe to pandas series

I need some help with a data types issue. I'm trying to convert a pandas dataframe, which looks like the following:

timestamp    number
2018-01-01     1
2018-02-01     0
2018-03-01     5
2018-04-01     0
2018-05-01     6

into a pandas series, which looks exactly like the dataframe, without the column names timestamp and number:

 2018-01-01     1
 2018-02-01     0
 2018-03-01     5
 2018-04-01     0
 2018-05-01     6

It shouldn't be difficult, but I'm having a little trouble figuring out the way to do it, as I'm a beginner in pandas.

It would be great to get some help with this issue.

Thank you very much in advance!

Upvotes: 2

Views: 683

Answers (1)

anky
anky

Reputation: 75080

IIUC, use:

df.set_index('timestamp')['number'].rename_axis(None)

2018-01-01    1
2018-02-01    0
2018-03-01    5
2018-04-01    0
2018-05-01    6

Upvotes: 3

Related Questions