python – Numpy相当于if / else list comprehension
发布时间:2021-01-17 10:41:39 所属栏目: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 – AssertionError:col应该是Column
- 创建虚拟环境(Python)中“virtualenv”和“-m venv”之间的
- python exceptions.UnicodeDecodeError:’ascii’编解码器
- python – WTForms SelectField没有正确地强制执行布尔值
- python模块之random
- django芹菜 – 如何发送request.FILES [‘photo’]到任务
- django – XSRF标题未在AngularJS中设置
- Python – 降低niceness值
- 具有多个’for’子句和单个’if’的python理解
- python – 应用引擎:字符串到datetime?