python - Numpy 返回“TypeError:'float' 对象不能被解释为整数”
问题描述
这是我的代码:
g = np.reshape(a,(len(a)/width,width))
p = g.astype(int)
print(p)
解决方案
len(a)/width
will return float
try len(a)//width
even better you can use -1 as first index and np will calculate for you
np.reshape(a,(-1,width))
推荐阅读
- python - 将来自异步调用的 API 响应分配给预先存在的 python 类实例
- python - 在kivy中更改页面滑动区域的大小
- amazon-web-services - 没有区域的 Amazon EC2 客户端构建器
- jenkins - 每当我通过单击“立即构建”选项执行作业时,Jenkins“轮询 SCM”选项就会自动启用
- javascript - 在 d3.js v6+ 中将元素标记为单击
- mongodb - 在 Mongoose 中使用聚合和查找
- java - 如何测试使用文件创建时间的方法
- python - 按 2 列(一列带有整数,一列带有字母数字)对 pandas 数据帧进行排序,整数列优先
- c++ - 通过基类中的方法触发派生类的添加方法
- r - 如何在 Rstudio connect api 中获取与用户 guid 关联的名称?