How to specify the index argument of Series in Ipython?

ipython

#1

I have created a Series using pandas library of Python

 In [4]: obj = Series([4, 7, -5, 3])
    In [5]: obj
    Out[5]:
    0 4
    1 7
    2 -5
    3 3

The index values are by default generated. I want to know is there a way by which we can specify the index of our choice like to replace (0,1,2,3) with (‘a’,‘b’,‘c’,‘d’)


#2

@sid100158,

You can add index argument to change the default value of index. Look at the below command to change the index:

from pandas import Series
test = Series([1,2,3,4,5], index=['a', 'b', 'c', 'd', 'e'])
test

Out[51]:
a    1
b    2
c    3
d    4
e    5
dtype: int64

Hope this helps!

Regards,
Sunil