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を使ったデータ分析、機械学習
140
3
章 
pandas
を使ったデータ操作
2010 25145561
筆者の経験上、実世界のデータを扱うための有用なパターンの
1
つが、こうしたインデクスの再
設定です。
3.6.5
 多重インデクスに基づいたデータ集約
pandas
には
mean()
sum()
max()
などのデータ集約メソッドが組み込まれていることを既に紹
介しました。階層的インデクスを持つデータの場合、これらのメソッドにはデータのサブセットを
制御するレベル・パラメータを渡すことができます。
医療データを使って調べてみましょう。
In[43]: health_data
Out[43]: subject Bob Guido Sue
type HR Temp HR Temp HR Temp
year visit
2013 1 31.0 38.7 32.0 36.7 35.0 37.2
2 44.0 37.7 50.0 35.0 29.0 36.7
2014 1 30.0 37.4 39.0 37.8 61.0 36.9
2 47.0 37.8 48.0 37.3 51.0 36.5
毎年
2
回行う検査の測定値を平均したいとしましょう。そのためには、調査したいインデクスの
レベル(この場合は年)を指定します。
In[44]: data_mean = health_data.mean(level='year')
data_mean
Out[44]: subjec
t Bob Guido Sue
type HR Temp HR Temp ...
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