Numpy Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 6: Line 6:


NumPy is the short for Numerical Python. It provides data structures, algorithms and library glue needed for most scientific applications involving numerical data in Python. NumPy contains:
NumPy is the short for Numerical Python. It provides data structures, algorithms and library glue needed for most scientific applications involving numerical data in Python. NumPy contains:
* A fast and efficient multidimensional array object <code>[[#ndarray|ndarray]]</code>. For numerical data, NumPy arrays are more efficient for storing and manipulating data than other built-in Python data structures.
* A fast and efficient multidimensional array object <code>[[#ndarray|ndarray]]</code>. For numerical data, NumPy arrays are more efficient for storing and manipulating data than other built-in Python data structures. The reason is that NumPy stores data in continuous block of memory, independent of other built-in Python objects. Also, NumPy library or algorithms is written in C and can operate on this memory without any type checking or other overhead.
* Functions for performing element-wise computations with arrays, and mathematical operations between arrays.
* Functions for performing element-wise computations with arrays, and mathematical operations between arrays.
* Tools for reading and writing array-based datasets to disk.
* Tools for reading and writing array-based datasets to disk.
Line 14: Line 14:
One of NumPy's primary uses is as a container for data to be passed between algorithms and libraries. NumPy is one of the most important foundational packages for numerical computing in Python and a dependency for [[Pandas_Concepts#Overview|Pandas]].
One of NumPy's primary uses is as a container for data to be passed between algorithms and libraries. NumPy is one of the most important foundational packages for numerical computing in Python and a dependency for [[Pandas_Concepts#Overview|Pandas]].


=<tt>ndarray</tt>=
NumPy does not provide time series manipulation, which is present in [[Pandas_Concepts#Overview|Pandas]].
Used to implement a Pandas [[Pandas_Series#Overview|Series]].
 
=Import Convention=
=Import Convention=
<syntaxhighlight lang='py'>
<syntaxhighlight lang='py'>
import numpy as np
import numpy as np
a = np.array(...)
</syntaxhighlight>
</syntaxhighlight>
Do not <code>from numpy import *</code>. The <code>numpy</code> namespace is large and contains a number of functions that conflict with built-in Python functions, like <code>min()</code> and <code>max()</code>.
=<tt>ndarray</tt>=
{{Internal|NumPy_ndarray#Overview|<tt>ndarray</tt>}}
=<tt>Pseudorandom Number Generation</tt>=
{{Internal|NumPy_Pseudorandom_Number_Generation#Overview|Pseudorandom Number Generation}}
=<tt>Universal Functions</tt>=
{{Internal|NumPy_Universal_Functions#Overview|Universal Functions}}

Latest revision as of 19:58, 20 May 2024

External

Internal

Overview

NumPy is the short for Numerical Python. It provides data structures, algorithms and library glue needed for most scientific applications involving numerical data in Python. NumPy contains:

  • A fast and efficient multidimensional array object ndarray. For numerical data, NumPy arrays are more efficient for storing and manipulating data than other built-in Python data structures. The reason is that NumPy stores data in continuous block of memory, independent of other built-in Python objects. Also, NumPy library or algorithms is written in C and can operate on this memory without any type checking or other overhead.
  • Functions for performing element-wise computations with arrays, and mathematical operations between arrays.
  • Tools for reading and writing array-based datasets to disk.
  • Linear algebra operations, Fourier transform, random number generation.
  • A mature C API to enable Python extensions and native C or C++ code to access NumPy's data structures.

One of NumPy's primary uses is as a container for data to be passed between algorithms and libraries. NumPy is one of the most important foundational packages for numerical computing in Python and a dependency for Pandas.

NumPy does not provide time series manipulation, which is present in Pandas.

Import Convention

import numpy as np

a = np.array(...)

Do not from numpy import *. The numpy namespace is large and contains a number of functions that conflict with built-in Python functions, like min() and max().

ndarray

ndarray

Pseudorandom Number Generation

Pseudorandom Number Generation

Universal Functions

Universal Functions