[回避] FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

将来的に削除される機能

FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
DeepL で翻訳すると、
FutureWarning: frame.append メソッドは非推奨で、将来のバージョンで pandas から削除される予定です。代わりに pandas.concat を使ってください。 となります。

遭遇事例

私の pandas の version は、1.4.1 です。

$ pip list | grep pandas
pandas 1.4.1

append を、以下のように使うと Warning になります。

Python

        import pandas as pd
        import numpy as np
    
        print('pandas version:', pd.__version__)
        # pandas version: 1.4.1
    
        df_a = pd.DataFrame(np.arange(1, 5).reshape(2, 2), columns=['col_1', 'col_2'])
        df_b = pd.DataFrame(np.arange(5, 9).reshape(2, 2), columns=['col_1', 'col_2'])
        df_c = df_a.append(df_b, ignore_index=True)

        print(df_a)
        #     col_1  col_2
        # 0      1      2
        # 1      3      4
        
        print(df_b)
        #     col_1  col_2
        # 0      5      6
        # 1      7      8

        print(df_c)
        #     col_1  col_2
        # 0      1      2
        # 1      3      4
        # 2      5      6
        # 3      7      8
    

指摘は、Error ではなく Warning なので、エラーにはなりませんが、コンソールには Warning 指摘がされています。

FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
df_c = df_a.append(df_b)

回避方法

回避は、指摘にある通り、concat を使用します。

Python

        df_a = pd.DataFrame(np.arange(1, 5).reshape(2, 2), columns=['col_1', 'col_2'])
        df_b = pd.DataFrame(np.arange(5, 9).reshape(2, 2), columns=['col_1', 'col_2'])
        df_c = pd.concat([df_a, df_b], axis=0, ignore_index=True)
    
エラー指摘が出力されなくなります。
axis=0 は、省略可能で、列方向に concat しています。
ignore_index=True の部分は、元の Index を無視し、新たな行番号の Index にしています。