Series is a one-dimensional data structure.
1
import pandas as pd
series = pd.Series([3, 6, 9])
print(series)
Execution result of 1
0 3
1 6
2 9
dtype: int64
There is an index in the leftmost column.
To change the index, write as follows
2
import pandas as pd
names = ["Tanaka", "Yamada", "Takahashi"]
series1 = pd.Series(names)
series2 = pd.Series(names, index=['a', 'b', 'c'])
print(series1)
print(series2)
Execution result of 2
0 Tanaka
1 Yamada
2 Takahashi
dtype: object
a Tanaka
b Yamada
c Takahashi
dtype: object
Recommended Posts