Multidimensional Array Object,
VariousDerived Objects (Such As Masked Arrays And Matrices),
Routines For Fast Operations On Arrays,
Mathematical, Logical, Shape Manipulation, Sorting, Selecting, I/O, Discrete Fourier Transforms, Basic
Linear Algebra, Basic Statistical Operations, Random Simulation And Much More.
Fortran to Python shim, f2py, provides an “easy” route to call fortran routines from python.
At the core of the NumPy package, is the ndarray object. This encapsulates n-dimensional arrays of homogeneous data
types, with many operations being performed in compiled code for performance.
Best For: raw array math, analysis manipulation. Anywhere coordinates/metadata aren’t critical
NumPy
4.
Pandas
pandas is afast, powerful, flexible and easy to use open source data analysis and manipulation tool,
built on top of the Python programming language.
NumPy arrays have one data type for the entire array, while pandas DataFrames have one data type per column.
Pandas adds, “indexes”, column names, operations across data types, relational indexing. Think any multi-data-type analysis.
A Dataframe is made up of 1-dimensional Series. A series is in essence a 1-d numpy array.
Best For: time-series analysis, relational 1-d data.
5.
xarray
Xarray introduces labelsin the form of dimensions, coordinates and attributes on top of raw NumPy-like multidimensional
arrays, which allows for a more intuitive, more concise, and less error-prone developer experience.
In Python, NumPy provides the fundamental data structure and API for working with raw ND arrays. However, real-world
datasets are usually more than just raw numbers; they have labels which encode information about how the array values
map to locations in space, time, etc.
Like Pandas builds on top of 1-d arrays, xarray builds on top of ND arrays. Geospatial data, model generated data.
Leverages ideas from the Unidata Common Data Model, to provide a powerful and concise interface to data.
Best For: n-d grids with coordinates, attributes, relational data.
6.
TC Tracks ->time, lat (float), lon (float), category (string), R34 (int/float)
GOES 16 IR scan -> latitude x longitude (floats)
Satellite orbit parameters -> time, lat, lon, altitude
GFS Relative Humidity -> hPa x lat x lon (floats)
When to use each:
Pandas -> 1-d series of multiple types
xarray -> 2-d grid (we’ll want to know where the data is located)
Pandas -> 1-d series
xarray -> 3-d grid (keep attributes of pressure, lat and lon with data)
7.
Remember numpy powersboth
Internal model simulation
numpy remove (small) overhead of xarray
Large or simple arrays where coords and metadata are superfluous
Numpy (really big arrays look at scipy.sparse matrices )
pd.Series.values -> numpy (any numpy operation works here)
xr.DataArray().values -> numpy (any numpy operation works here)