python – Numpy相当于if / else list comprehension
发布时间:2021-01-17 05:05:28 所属栏目:Python 来源:互联网
导读:有一种笨拙的做法 n = [x-t if x 0 else x for x in nps] 与此类似 n = np.array(a)n[np.abs(n) t] = 0 也许这样的事情? n[n 0] = n-t 现在不能测试,但试试 np.where(n 0, n - t, n) 见documentation
|
有一种笨拙的做法 n = [x-t if x > 0 else x for x in nps] 与此类似 n = np.array(a) n[np.abs(n) < t] = 0 也许这样的事情? n[n > 0] = n-t 解决方法现在不能测试,但试试np.where(n > 0,n - t,n) 见documentation (编辑:东莞站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Python绘图:如何使matplotlib.pyplot停止强制我的标记的样
- Python __init__.py和类
- python – 运算符混淆
- python – 基本的openGL,顶点缓冲区和pyglet
- python – CherryPy日志记录:如何配置和使用全局和应用程序
- TypeError:’function’对象不可订阅 – Python
- gettext – Flask-Babel如何在Jinja模板文件中使用翻译
- 一个基于python的PowerShell?
- Django ForeignKey,null = True,内连接和左外连接
- dict.viewkeys()返回的数据类型是什么? [python 2.7]
