NumPy配列の詳細

MATLABユーザーのためのPython

Justin Kiggins

Product Manager

NumPy配列の計算

print(radius)
[[1, 2, 3]]
type(radius)
 <class 'numpy.ndarray'>
area = np.pi * (radius ** 2)
print(area)
[3.14159265 12.56637061 
28.27433388]
演算 演算子
加算 +
減算 -
乗算 *
除算 /
べき乗 **
MATLABユーザーのためのPython

NumPy配列間の算術演算

type(revenue)
<class 'numpy.ndarray'>
print(revenue)
[[100, 114, 96, 120]]
type(cost)
<class 'numpy.ndarray'>
print(cost)
[102. 104. 101. 102.]
profit = revenue - cost
print(profit)
[-2. 10. -5. 18.]
MATLABユーザーのためのPython

NumPy配列のデータ集計

import numpy as np

np.mean(revenue)
107.5

便利なNumPy関数:

  • np.min() 配列の最小値を返す
  • np.max() 配列の最大値を返す
  • np.sum() 配列の合計値を返す
MATLABユーザーのためのPython

練習しましょう!

MATLABユーザーのためのPython

Preparing Video For Download...