直訳
今後の警告: dataframe.append メソッドは非推奨、将来のバージョンで pandas から削除する予定だから代わりに pandas.concat を使用してね
Ver1.4以降非推奨となっている
dataframeを結合(追加)するときに利用するメソッドで以下の様なサンプルでワーニングが出る
import pandas as pd
import numpy as np
# dataframeのカラム設定用リスト定義
COL_LIST = ['no','name','level','type1','type2','helditem']
# 結合用のdataframe作成
df1 = pd.DataFrame([[25,'pika',88,'Electric',np.NaN,np.NaN],
[131,'rara',80,'Water','Ice',np.NaN],
[143,'gon',82,'Normal',np.NaN,np.NaN]],
columns=COL_LIST)
# 結合用のdataframe作成
df2 = pd.DataFrame([[3,'fushi',84,'Grass','Poison',np.NaN],
[6,'kage',84,'Fire','Flying',np.NaN],
[9,'kame',84,'Water',np.NaN,np.NaN]],
columns=COL_LIST)
df1 = df1.append(df2)
# df1を追加したdf確認
print(df1)
"""
no name level type1 type2 helditem
0 25 pika 88 Electric NaN NaN
1 131 rara 80 Water Ice NaN
2 143 gon 82 Normal NaN NaN
3 3 fushi 84 Grass Poison NaN
4 6 kage 84 Fire Flying NaN
5 9 kame 84 Water NaN NaN
"""
対処法
import pandas as pd
import numpy as np
# dataframeのカラム設定用リスト定義
COL_LIST = ['no','name','level','type1','type2','helditem']
# 結合用のdataframe作成
df1 = pd.DataFrame([[25,'pika',88,'Electric',np.NaN,np.NaN],
[131,'rara',80,'Water','Ice',np.NaN],
[143,'gon',82,'Normal',np.NaN,np.NaN]],
columns=COL_LIST)
# 結合用のdataframe作成
df2 = pd.DataFrame([[3,'fushi',84,'Grass','Poison',np.NaN],
[6,'kage',84,'Fire','Flying',np.NaN],
[9,'kame',84,'Water',np.NaN,np.NaN]],
columns=COL_LIST)
# df1 = df1.append(df2)
df1 = pd.concat([df1,df2]) # ←こっちに変更
# df1を追加したdf確認
print(df1)
"""
no name level type1 type2 helditem
0 25 pika 88 Electric NaN NaN
1 131 rara 80 Water Ice NaN
2 143 gon 82 Normal NaN NaN
3 3 fushi 84 Grass Poison NaN
4 6 kage 84 Fire Flying NaN
5 9 kame 84 Water NaN NaN
"""
コメント