【问题标题】:What does rr.reshape(rr,(a,b)) TypeError: only integer scalar arrays can be converted to a scalar index什么 rr.reshape(rr,(a,b)) TypeError: only integer scalar arrays can be convert to a scalar index
【发布时间】:2019-12-11 04:04:30
【问题描述】:

错误是什么 rr.reshape(rr,(a,b)) TypeError:只有整数标量数组可以转换为标量索引 我无法理解我的数组只是一维的,但我无法执行整形操作。

我看到我的数组是一维的,但我无法执行重塑 操作

import numpy
a1=[]
a2=[]
a,b =(raw_input().split())
a=int(a)
b=int(b)
a1=raw_input().split()
a2=raw_input().split()
a1=list(map(int,a1))
a2=list(map(int,a2))
a1.extend(a2)
rr=numpy.array(a1)
print(rr)
rr.reshape(rr,(a,b))"""THe error line"""
print(rr)

请帮我做这个程序

【问题讨论】:

标签: python numpy transpose


【解决方案1】:

numpy 中使用reshape 你可以这样做

arrayname.reshape(shape)

numpy.reshape(arrayname, shape)

所以使用rr.reshape((a,b))

一般来说,在发布此类问题之前,请尝试查看documentation。您发布的大部分代码与问题无关。尝试构建一个最小的工作示例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-03
    • 1970-01-01
    • 2018-07-28
    • 2021-04-01
    • 2022-12-01
    • 1970-01-01
    • 2020-12-20
    • 2021-03-19
    相关资源
    最近更新 更多