用于将数组或矩阵转换成列表

实例:

import numpy as np
a = np.ones(5)  # array([1., 1., 1., 1., 1.])
a.tolist()  # [1.0, 1.0, 1.0, 1.0, 1.0]
b = [[1, 2, 3], [0, 9, 8, 0]]
c = np.mat(b)  # matrix([[list([1, 2, 3]), list([0, 9, 8, 0])]])
c.tolist()  # [[1, 2, 3], [0, 9, 8, 0]]

在对数据集预处理时常会用到

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案