python - 在 Python 中使用列表更改二维数组中的值范围
问题描述
在 python 中,我有一个大小为 13 的二维数组,每个元素都是大小为 16 的列表。我想使用以下方法将此数组中的所有值转换为不同的范围。
((old value - old min)/(old max - old min)) * (new max - new min) + new min
我正在使用类似的东西 -
a_list = [1, 2, 3]
multiplied_list = [element * 2 for element in a_list]
print(multiplied_list)
我收到以下错误
"unsupported operand type(s) for -: 'list' and 'int' "
谢谢你的帮助!
解决方案
我想通了,我必须使用 numpy.array() 将二维数组从列表转换为浮点数组
推荐阅读
- java - RecyclerView 中的两次数据
- flutter - 如何一次从 OverlayState 中删除所有 OverlayEntry?
- swift - 如何在 macOS 应用程序上调试 Core Data Cloudkit 崩溃
- python - Tkinter 错误:“_tkinter.TclError:无效的命令名称“.!frame.!entry”PYTHON
- .net - Microsoft Sync Framework for SQL Server CE 和 SQL Server 同步对于列数据类型 real 和 float 失败
- react-native - TypeError:未定义不是对象(_reactNative.Animated.Text.propStyles.style)
- c++11 - c++11:在构造时在基类之间分派参数
- date - 日期自动更改(日期和月份)
- lua - table.insert 添加未知表
- angular - Angular 8 Ngx-image-cropper 不是 Angular 模块 - 导入错误