Hound
Hound

Reputation: 972

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.

Upvotes: 0

Views: 61

Answers (1)

aensm
aensm

Reputation: 3607

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

Upvotes: 1

Related Questions