Convert pandas data frame to series

后端 未结 6 1469
忘了有多久
忘了有多久 2020-11-30 21:52

I\'m somewhat new to pandas. I have a pandas data frame that is 1 row by 23 columns.

I want to convert this into a series? I\'m wondering what the most pythonic way

6条回答
  •  遥遥无期
    2020-11-30 22:04

    You can also use stack()

    df= DataFrame([list(range(5))], columns = [“a{}”.format(I) for I in range(5)])
    

    After u run df, then run:

    df.stack()
    

    You obtain your dataframe in series

提交回复
热议问题