Converting Python list to Pandas Series
Start your free 7-days trial now!
To convert a Python list into a Pandas Series, directly pass the list into the
my_list = [3,6]s = pd.Series(my_list)s0 31 6dtype: int64
To add an index to this Series:
my_list = [3,6]s = pd.Series(my_list, index=["a","b"])sa 3b 6dtype: int64
Note that the returned Series has a new copy of the data, that is, modifying
s will not mutate the original list and vice versa.