Unlocking the Power of NumPy, Pandas, and Xarray for Data Manipulation

numpy pandas xarray n.w
1 / 9
Embed
Share

"Discover the capabilities of NumPy for array operations, Pandas for data analysis, and Xarray for labeled array management. Learn when to use each tool for efficient data handling in Python projects."

  • NumPy
  • Pandas
  • Xarray
  • Data Manipulation
  • Python

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Numpy pandas xarray

  2. Introduction links: https://numpy.org/doc/stable/user/index.html https://pandas.pydata.org/docs/getting_started/index.html http://xarray.pydata.org/en/stable/

  3. NumPy Multidimensional Array Object, Various Derived 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

  4. Pandas pandas is a fast, 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 labels in 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. When to use each: TC Tracks -> time, lat (float), lon (float), category (string), R34 (int/float) Pandas -> 1-d series of multiple types GOES 16 IR scan -> latitude x longitude (floats) xarray -> 2-d grid (we ll want to know where the data is located) Satellite orbit parameters -> time, lat, lon, altitude Pandas -> 1-d series GFS Relative Humidity -> hPa x lat x lon (floats) xarray -> 3-d grid (keep attributes of pressure, lat and lon with data)

  7. Remember numpy powers both 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)

  8. Simple Demo comparing methods Xarray Numpy Pandas quick comparison notebook https://colab.research.google.com/drive/1uK3S9Ml3e4bpDoHB_A9bBwgJu6nmSNkl?usp=sharing

  9. Docs: https://numpy.org/doc/stable/reference/index.html https://pandas.pydata.org/docs/reference/index.html https://xarray.pydata.org/en/stable/api.html

More Related Content