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を使ったデータ分析、機械学習
166
3
章 
pandas
を使ったデータ操作
効なメソッドは、
GroupBy
オブジェクトに対しても使用できることを覚えておきましょう。これに
より、非常に柔軟で強力な操作が可能になります。
3.9.3.3
 集約、フィルタ、変換、適用
前述の議論では、結合操作に対する集約に重点を置いて説明しましたが、利用できるのはこれだ
けではありません。特に、
GroupBy
オブジェクトには、グループ化したデータを結合する前に、さ
まざまな操作を効率的に実装するための
aggregate()
(集計)、
filter()
(フィルタ)、
transform()
(変換)、
apply()
(適用)メソッドがあります。
以降の説明では、次の
DataFrame
を使います。
In[19]: rng = np.random.RandomState(0)
df = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],
'data1': range(6),
'data2': rng.randint(0, 10, 6)},
columns = ['key', 'data1', 'data2'])
df
Out[19]: key data1 data2
0 A 0 5
1 B 1 0
2 C 2 3
3 A 3 3
4 B 4 7
5 C 5 9
集約
既に
sum()
median()
などを
GroupBy
に対して適用した例を見ていますが、
aggregate()
メソッ
ドを使用するとさらに柔軟な操作が可能となります。文字列、関数、またはそのリストを取り、す ...
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