knaka Tech-Blog

AI, IoT, DIYエレクトロニクス, データサイエンスについて投稿予定です。

pandas Series

必要な import

import numpy as np
import numpy.random as random
import pandas as pd
from pandas import Series, DataFrame

配列の作成

# Series
a1 = pd.Series([5,6,7,8,9])
print(a1)
a1 = pd.Series(np.arange(5, 10 ,dtype='f'))
print(a1 )

結果:

0    5
1    6
2    7
3    8
4    9
dtype: int64
0    5.0
1    6.0
2    7.0
3    8.0
4    9.0
dtype: float32

index が自動で付与されるようです。

a1.index

結果:

RangeIndex(start=0, stop=5, step=1)


index の表示ができました。