Python基础——numpy.ndarray一维数组与多维数组
2015-12-01 12:28
495 查看
shape为(3, 1)(表多维数组)与shape为(3, )(表一维数组)用法上有很大的不同
>>> x = np.random.randn(3) >>> x array([ 0.53150381, -0.45205789, -0.6655509 ]) >>> x.shape (3,) >>> y = np.random.randn(3, 1) >>> y array([[ 0.69918993], [ 1.17769064], [-0.53024913]]) >>> y.shape (3, 1)
不同之一:与list进行转换
>>> list(x) [0.53150381185761253, -0.45205789280422431, -0.66555089846812798] >>> list(y) [array([ 0.69918993]), array([ 1.17769064]), array([-0.53024913])]
相关文章推荐
- Numpy中的广播(Broadcasting)
- Python技巧——list comprehension 与 functools.reduce
- Python类
- python中的字典排序!
- Python数据分析入门
- 推荐Python、Django中文文档地址
- python学习系列之python装饰器基础(6)---装饰器加参数
- python抓取网页中图片并保存到本地
- Python入门
- bat脚本调用python
- ubuntu python PyCharm virtualenv
- rocks快速添加节点
- python转C的内存泄露问题
- Python缩小图像
- 浅析Python编码问题
- Python—OpenCV学习网站
- python单元测试框架nose的扩展nose-ittr支持传参测试
- python的unittest单元测试框架改装传参
- Python 基础
- python:ImportError: No module named dpkt