首页 > 解决方案 > 将多个 DataFrame 转换为 numpy 数组

问题描述

我正在尝试将 5 个数据帧循环转换为 numpy 数组。

df = [df1, df2, df3, df4, df5]

for index, x in enumerate(df):
  x = x.to_numpy()

print(type(df3)) 仍然给我 pandas DataFrame 作为输出。

标签: python-3.xpandasnumpy

解决方案


此剂量不会保存到环境中

for index, x in enumerate(df):
  df[index] = x.to_numpy()

然后你做

df[0]

推荐阅读