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を使ったデータ分析、機械学習
146
3
章 
pandas
を使ったデータ操作
3 NaN B3 C3
4 NaN B4 C4
pd.concat
関数の引数を組み合わせることで、データセットのさまざまな結合が可能になります。
データの結合を行う際には、このことを思い出してください。
3.7.2.3
append
メソッド
配列の連結は非常に一般的であるため、
Series
および
DataFrame
オブジェクトには、より少な
いキーストロークで同じことを実行する
append
メソッドがあります。例えば、
pd.concat([df1,
df2])
を呼び出すのではなく、単に
df1.append(df2)
で同じことができます。
In[16]: print(df1); print(df2); print(df1.append(df2))
df1
df2 df1.append(df2)
A B A B A B
1 A1 B1 3 A3 B3 1 A1 B1
2 A2 B2 4 A4 B4 2 A2 B2
3 A3 B3
4 A4 B4
Python
リストの
append()
extend()
メソッドとは異なり、
pandas
append()
メソッドは元の
オブジェクトを変更せず、結合されたデータで新しいオブジェクトを作成することに注意してくだ
さい。新しいインデクスとデータバッファを作成するため、それほど効率的な方法でもありません。
したがって
、複数の追加操作を行う場合は、連結する
DataFrame
のリストを
concat()
関数に渡して
一度に処理する方法が一般的です。 ...
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