NumPy学习指南1

What is NumPy?

NumPy (short for numerical Python) is an open source Python library for scientific computing. It lets you work with arrays and matrices in a natural way. 

In a way, NumPy replaces some of the functionality of MATLAB and Mathematica, allowing rapid interactive prototyping.

NumPy code is much cleaner than straight Python code and it tries to accomplish the same tasks.  NumPy's arrays are stored more efficiently than an equivalent data structure in base Python, such as a list of lists.

Large portions of NumPy are written in C. This makes NumPy faster than pure Python code.

The drawback of NumPy arrays is that they are more specialized than plain lists. Outside the context of numerical computations, NumPy arrays are less useful.

If you are a Java programmer, you might be interested in Jython, the Java implementation of Python. In that case, I have bad news for you. Unfortunately, Jython runs on the Java Virtual Machine and cannot access NumPy because NumPy's modules are mostly written in C.

>>> import numpy as np
>>> a = np.arange(3) ** 2
>>> b = np.arange(3) ** 3
>>> a + b
array([ 0,  2, 12], dtype=int32)
>>> print(a+b)
[ 0  2 12]

注意结果没有逗号隔开!

Obviously, we are not dealing with a Python list but with a NumPy array. NumPy arrays are specialized data structures for numerical data.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值