LoginSignup
2
2

More than 3 years have passed since last update.

Pandas 操作 備忘録

Last updated at Posted at 2020-01-12

同じところでつまづきたくないので、メモ書き。

indexを無視して列を追加

df_1 = df_1.reset_index(drop=True)
df_2['xxx'] = df_1['xxx']
  • 基本的には2行目のみで良い
  • 下記の場合は1行目が必要
    • indexが0からの連番になっていない場合
      • 予期せぬソートが行われている可能性がある
    • indexに重複がある場合
      • 重複されたindexのデータが複製される

理由

  • df_1のindexをキーとして結合するため

カラム名強制変換

df.columns = ['aaa', 'bbb', 'ccc', ...]
2
2
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
2
2