python numpy 笔记(一)

这篇笔记详细介绍了numpy的基础操作,包括获取numpy版本、数组元素判断(如非零、有限、无穷、NaN)、元素比较、随机数生成、数组创建与迭代、文件保存与加载等,帮助理解numpy在Python中的应用。
摘要由CSDN通过智能技术生成

numpy basic

1.Write a NumPy program to get the numpy version and show numpy build configuration.

np.__version__
np.show_config()

2. Write a NumPy program to get help on the add function.

np.info(np.add)

3. Write a NumPy program to test whether none of the elements of a given array is zero.

x = np.array([1, 2, 3, 4])
np.all(x)

4. Write a NumPy program to test whether any of the elements of a given array is non-zero.

np.any(x)

5. Write a NumPy program to test a given array element-wise for finiteness (not infinity or not a Number).

x = np.array([1, 2, np.nan, np.inf])
np.isfinite(x)

6. Write a NumPy program to test element-wise for positive or negative infinity.

np.isinf(x)

7. Write a NumPy program to test element-wise for NaN of a given array.

np.isnan(x)

8. Write a NumPy program to test element-wise for complex number, real number of a given array. Also test whether a given number is a scalar type or not.

np.iscomplex()
np.isreal()
np.isscalar()
np.isscalar(3.1) True
np.isscalar([3.1]) False

<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值