質問
pandas.appendの値を追加すると、以下が出力されます。
pandas.appendからpandas.concatの変更をおすすめされていますが、
pandas.concatを調べるとはDataFrame同士の結合に使用するみたいです。
空のDataFrameと追加したいDataFrameを作成して結合する方法しかないでしょうか?
python3
1import pandas as pd 2 3df = pd.DataFrame(columns = ['Name' , 'Price', 'Stock']) 4#Add new ROW 5df = df.append({'Name' : 'Apple' , 'Price' : 23, 'Stock' : 'No'} , ignore_index=True) 6df = df.append({'Name' : 'Mango' , 'Price' : 13, 'Stock' : 'Yes'} , ignore_index=True) 7print(df) 8 9 10###出力結果 11FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. 12 df = df.append({'Name' : 'Apple' , 'Price' : 23, 'Stock' : 'No'} , ignore_index=True) 13FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. 14 df = df.append({'Name' : 'Mango' , 'Price' : 13, 'Stock' : 'Yes'} , ignore_index=True) 15 Name Price Stock 160 Apple 23 No 171 Mango 13 Yes

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。