我有以下数据框,但需要将其作为numpy数组传递给Keras。我需要保留month,year,shop_id和item_id列,但是numpy数组会删除它们,只保留item_category_id和avg_item_price。
month year shop_id item_id item_category_id avg_item_price
01 2013 0 32 160 147.333328
33 111 347.000000
35 40 247.000000
最后,它说有
[32920 rows x 2 columns]
答案 0 :(得分:1)
您将这些列用作熊猫的索引,则必须重置它们:
df = df.reset_index()