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を使ったデータ分析、機械学習
118
3
章 
pandas
を使ったデータ操作
Out[13]: A B C
0 1.0 15.0 NaN
1 13.0 6.0 NaN
2 NaN NaN NaN
それぞれのオブジェクト内の順序に関係なく、インデクスは正しく整列され、結果がソートされ
ることに注意してください。
Series
の場合と同様に演算メソッドを使用して、欠損値として要素
に埋める任意の値を指定できます。ここでは、(
A
の行を
stack()
で積み重ねて計算する)
A
のすべ
ての値平均を指定します。
In[14]: fill = A.stack().mean()
A.add(B, fill_value=fill)
Out[14]: A B C
0 1.0 15.0 13.5
1 13.0 6.0 4.
5
2 6.5 13.5 10.5
表3-1に、
Python
演算子と等価な
pandas
オブジェクトメソッドを示します。
表3-1 Python演算子と対応する pandasメソッド
Python演算子 pandasメソッド
+ add()
- sub()
,
subtract()
* mul()
,
multiply()
/ truediv()
,
div()
,
divide()
// floordiv()
% mod()
** pow()
3.4.3
ufunc: DataFrame
Series
との演算
DataFrame
Series
間で操作を実行する場合、インデクスと列の配置も同様に維持されます。
DataFrame
Series
間の操作は、
2
次元と
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