Skip to Content
Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習
book

Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

by Jake VanderPlas, 菊池 彰
May 2018
Intermediate to advanced
556 pages
13h 21m
Japanese
O'Reilly Japan, Inc.
Content preview from Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習
2.2
NumPy
配列の基礎
43
もう
1
つの有用な属性は、配列のデータ型である
dtype
です(これについては、「2.1 Python
データ型について」で取り上げました)。
In[3]: print("dtype:", x3.dtype)
dtype: int64
その他の属性には、各配列要素のサイズ(バイト単位)を表す
itemsize
と、配列の合計サイズ(バ
イト単位)を表す
nbytes
があります。
In[4]: print("itemsize:", x3.itemsize, "bytes")
print("nbytes:", x3.nbytes, "bytes")
itemsize: 8 bytes
nbytes: 480 bytes
一般的に、
nbytes
itemsize
size
を乗じた値と同じになります。
2.2.2
 配列インデクス:配列の要素にアクセスする
Python
標準リストのインデ
クスに精通しているなら、
NumPy
のインデクスにも精通していると
言えます。
1
次元配列では、
Python
リストの場合と同様に、必要なインデクスを角カッコで指定す
ることで、
i
番目(
0
から開始します)の値にアクセスできます。
In[5]: x1
Out[5]: array([5, 0, 3, 3, 7, 9])
In[6]: x1[0]
Out[6]: 5
In[7]: x1[4]
Out[7]: 7
配列の最後からの指定では、負のインデクスを使用できます。
In[8]: x1[-1]
Out[8]: 9
In[9]: x1[-2] ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pythonデータサイエンスハンドブック 第2版 ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

Pythonデータサイエンスハンドブック 第2版 ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

Jake VanderPlas, 菊池 彰
初めてのGraphQL ―Webサービスを作って学ぶ新世代API

初めてのGraphQL ―Webサービスを作って学ぶ新世代API

Eve Porcello, Alex Banks, 尾崎 沙耶, あんどうやすし

Publisher Resources

ISBN: 9784873118413Other