AttributeError: ‘DataFrame’ object has no attribute ‘as_matrix’

  • Post author:
  • Post category:其他




pandas版本如下

import pandas
pandas.__version__

‘1.0.0’



执行如下代码报错

base_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(base_dir, 'data/fix_data_tai3.csv')
train_df = pd.read_csv(file_path)
train_np = train_df.as_matrix()

报错代码:AttributeError: ‘DataFrame’ object has no attribute ‘as_matrix’



处理方法

base_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(base_dir, 'data/fix_data_tai3.csv')
train_df = pd.read_csv(file_path)
#train_np = train_df.as_matrix()
train_np = train_df.iloc[:,:].values



版权声明:本文为hellosmile123456原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。