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を使ったデータ分析、機械学習
110
3
章 
pandas
を使ったデータ操作
5 c
dtype: object
整数インデクスにおけるこうした潜在的な混乱に対応するために、
pandas
は特定の指定方法を
明示的に示すための特別なインデクス属性をいくつか用意しています。これらはメソッドではな
く、
Series
のデータ対して特定のスライス指定を行うための属性です。
loc
属性を使用すると、明示的なインデクスを使ったインデクスおよびスライスが可能になりま
す。
In[14]: data.loc[1]
Out[14]: 'a'
In[15]: data.loc[1:3]
Out[15]: 1 a
3 b
dtype: object
iloc
属性は間接的な
Python
スタイルのインデクスを使ったインデクスとスライスを可能にしま
す。
In[16]: data.iloc[1]
Out[16]: 'b'
In[17]: d
ata.iloc[1:3]
Out[17]: 3 b
5 c
dtype: object
3
番目のインデクス属性
ix
は、これら
2
つのハイブリッドであり、
Series
オブジェクトに対して
は標準の
[]
ベースインデクスと同等に機能します。
ix
属性の目的は、
DataFrame
オブジェクトへ対
する場合に明確になります。これについては、後で説明します。
Python
コードの基本的な原則の
1
つは、「暗示するより明示する方が良い」です。
loc
iloc
の明
示的な使用は、きれいで読みやすいコードを維持するのに非常に役立ちます。特に整数インデクス
の場合は、これらの両方を使用してコードを読みやすく理解しやすくし、インデクスとスライスの ...
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