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を使ったデータ分析、機械学習
48
2
章 
NumPy
の基礎
In[42]: # column vector via newaxis newaxis
を用いた列ベクトルの作成
x[:, np.newaxis]
Out[42]: array([[1],
[2],
[3]])
この種類の変換は、本書を通して頻繁に使用します。
2.2.5
 配列の連結と分割
「2.2.4 配列の形状変更」で述べた処理はすべて
1
つの配列に対して動作します。また、
1
つの配
列を複数の配列に分割することもできます。ここでは、こうした操作について学びます。
2.2.5.1
 配列の連結
NumPy
2
は、
np.concatenate
np.vstack
np.hstack
によって実行します。
np.concatenate
は、最初の引数としてタプルまたは配列のリスト
を取ります。
In[43]: x = np.array([1, 2, 3])
y = np.array([3, 2, 1])
np.concatenate([x, y])
Out[43]: array([1, 2, 3, 3, 2, 1])
一度に
2
つ以上の配列を連結することもできます。
In[44]: z = [99, 99, 99]
print(np.concatenate([x, y, z]))
[ 1 2 3 3 2 1 99 99 99]
np.concatenate
は、
2
次元配列に対しても使用できます。
In[45]: grid ...
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