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を使ったデータ分析、機械学習
124
3
章 
pandas
を使ったデータ操作
pandas
は文字列データを、常に
object
dtype
として格納することに注意してください。
3.5.3
null
値が存在する場合の処理
今まで見てきたように、
pandas
None
NaN
を欠損値または
null
値を示すために基本的に交換可
能としています。この規約を容易にするために、
pandas
データ構造の
null
値を検出、削除、および
置換するための有用なメソッドがいくつかあります。
isnull()
欠損値の存在を示すブール値マスク配列を作成する
notnull()
isnull()
の逆
dropna()
データから欠損値を取り除いたデータを作る
fillna()
不足している要素に値を埋め込んだデータのコピーを返す
これらのメソッドの簡単な使用例を、この後で紹介します。
3.5.3.1
null
値の検出
pandas
のデータ構造には、
null
値を検出するための
2
つの便利なメソッド
isnull()
notnull()
が用意されています。いずれの場合も、データに対するブール値マスクが戻されます。例を見てみ
ましょう。
In[13]: data = pd.Series([1, np.nan, 'hello', None])
 
In[14]: data.isnull()
Out[14]: 0 False
1 True
2 False
3 True
dtype: bool
「3.3 インデクスとデータの選択」で説明したように、ブール値マスクは
Series
のインデクスま
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