简体   繁体   中英

Getting the columns of a pandas series

I have a pandas.core.series as such:

140228202800    25
130422174258     5
131213194708     3
130726171426     1

I would like to get the first column and second column separately

Column 1:

140228202800
130422174258
131213194708
130726171426

Column 2:

25
5
3
1

I tried the following but no luck.

my_series.iloc[:,0]
my_series.loc[:,0]
my_series[:,0]

The first "column" is the index you can get it using s.index or s.index.to_list() to get obtain it as a list.

To get the series values as a list use s.to_list and in order to get it as a numpy array use s.values .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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