简体   繁体   中英

Series Index Pandas

I have a very simple question. I have this series

[in]: item_series
[out]: item_nbr
       9           27396
       28           4893
       40            254
       47           2409

Now I have a for loop

for j in item_series:
    print j

Right now this prints: 27396, 4893, 254, 2409. How can I get it to print the item number? In this example: 9, 28, 40, 47.

You can access the index of a pandas Series using item_series.index

So for your example

for j in item_series.index:
    print j

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