0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Data Frameを結合する方法

Last updated at Posted at 2023-02-14

目的

dfを横方向に連結して表示したい。

結論

連結なので今回はcontact()を使用する。
横方向に連結したいので、axis=1とする。

お試し

import pandas as pd

df1 = pd.DataFrame({"名前": ["田中", "佐藤", "鈴木"], 
                    "出身地": ["北海道", "青森", "秋田"], 
                    "チーム": ["チームA", "チームB", "チームB"]})
df2 = pd.DataFrame({"test1": ["田中", "佐藤", "鈴木"], 
                    "test2": ["北海道", "青森", "秋田"], 
                    "test3": ["チームA", "チームB", "チームB"]})
print(pd.concat({"Data1":df1, "Data2":df2}, axis=1))

<実行結果>
image.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?