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.6
 比較、マスク、ブール論理
69
In[22]: %matplotlib inline
import matplotlib.pyplot as plt
In[23]: plt.imshow(z, origin='lower', extent=[0, 5, 0, 5],
cmap='viridis')
plt.colorbar();
この
2
次元関数を可視化した結果を図2-5に示します。
図2-5 2次元の配列の可視化
2.6
 比較、マスク、ブール論理
この節では、ブール値マスクを使用して
NumPy
配列内の値を調べて操作する方法について説明
します。マスキングは、何らかの基準に基づいて配列内の値を抽出、変更、カウントするなどの操
作を行う場合に使用します。例えば、ある値よりも大きな値をすべて数えたり、閾値を超えた外れ
値をすべて取り除くなどです。ブール値マスクは、
NumPy
でこれらの作業を実行する最も効率的
な方法です。
2.6.1
 事例:雨天日数
ある都市の毎年の降水量を表す一連のデータがあるとします。ここではシアトル市の
2014
年の
日次降水量統計
1
pandas
(第
3
章で詳しく説明します)を使って読み込みます。
In[1]: import numpy as np
import pandas as pd
pandas
を使用して降水量(インチ)を
NumPy
配列として読み込む
# use pandas to extract rainfall inches as a NumPy array
rainfall ...
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