栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

数值python(numpy库) 常用函数用法整理

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

数值python(numpy库) 常用函数用法整理

1 any()

Test whether any array element along a given axis evaluates to True.

print(np.any([]), np.any([1, 2]), np.any(np.nan), 
	  np.any(()), np.any(np.array([True, True, True])), 
	  np.any(np.array([False, False])))
# res: False True True False True False
# 补充:(np.nan == False) 为 False
2 ravel()

Return a contiguous flattened array.

a = np.array([[1,2,3], [4,5,6]])
print(a, 'n-----------n', a.ravel())
# res: 
'''
[[1 2 3]
 [4 5 6]] 
-----------
 [1 2 3 4 5 6]
'''
3 concatenate()

Join a sequence of arrays along an existing axis.

a = np.array([[1,2,3], [4,5,6]])
b = np.array([7,8,9]).reshape(1, -1)
print(np.concatenate((a, b)))
# res:
'''
[[1 2 3]
 [4 5 6]
 [7 8 9]]
'''
4 c_()

Translates slice objects to concatenation along the second axis.

a = np.array([[1,2,3], [4,5,6]])
b = np.array([7,8])
print(np.c_[a, b])
# res:
'''
[[1 2 3 7]
 [4 5 6 8]]
'''
5 logical_and()

Compute the truth value of x1 AND x2 element-wise.

print(np.logical_and(True, False), np.logical_and(True, True))
# res: False True

还有其他逻辑函数也同理


持续更新


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/942595.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号