You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python is an interpreted language, and many features that make development rapid with Python are a result of that, with the price of reduced performance in many cases.
616
+
Python is an interpreted language, and many features (dynamical typing, flexible data structures) that make development rapid with Python are a result of that, with the price of reduced performance in many cases.
617
617
618
-
- Dynamic typing
619
-
- Flexible data structures
618
+
There are some packages that are more efficient than Numpy and Pandas.
620
619
621
-
- There are some packages that are more efficient than Numpy and Pandas.
620
+
- `SciPy <https://docs.scipy.org/doc/scipy/reference/>`_ is a library that builds on top of NumPy.
622
621
623
-
- `SciPy <https://docs.scipy.org/doc/scipy/reference/>`_ is a library that builds on top of NumPy.
624
-
625
-
- It contains a lot of interfaces to battle-tested numerical routines written in Fortran or C, as well as Python implementations of many common algorithms.
626
-
- Reads NETCDF!
627
-
628
-
- `ENCCS course material <https://enccs.github.io/hpda-python/stack/#scipy>`_
622
+
- It contains a lot of interfaces to battle-tested numerical routines written in Fortran or C, as well as Python implementations of many common algorithms.
623
+
- Reads NETCDF!
624
+
- `ENCCS course material <https://enccs.github.io/hpda-python/stack/#scipy>`_
629
625
630
626
Xarray package
631
627
..............
632
628
633
-
- ``xarray`` is a Python package that builds on NumPy but adds labels to **multi-dimensional arrays**.
629
+
``xarray`` is a Python package that builds on ``NumPy`` but adds labels to **multi-dimensional arrays**.
634
630
635
-
- 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.
636
-
- It also **borrows heavily from the Pandas package for labelled tabular data** and integrates tightly with dask for parallel computing.
631
+
- **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.
632
+
- **borrows from the Pandas package for labelled tabular data** and integrates tightly with ``dask`` for parallel computing.
637
633
638
-
- Xarray is particularly tailored to working with NetCDF files.
639
-
- But work for another files as well
634
+
- particularly tailored to working with NetCDF files.
635
+
- work for another file formats as well
640
636
641
637
- Explore it a bit in the (optional) exercise below!
642
638
@@ -645,42 +641,45 @@ Dask
645
641
646
642
How to use more resources than available?
647
643
648
-
.. image:: ../img/when-to-use-pandas.png
649
-
:width:600 px
644
+
.. admonition:: Remember this image? ;-)
645
+
:class: dropdown
646
+
647
+
.. image:: ../img/when-to-use-pandas.png
648
+
:width:600 px
650
649
651
650
Dask is very popular for data analysis and is used by a number of high-level
652
-
Python libraries:
651
+
Python libraries.
653
652
654
-
- Dask is composed of two parts:
653
+
2 parts:
655
654
656
-
- **Dask Clusters**
657
-
- Dynamic task scheduling optimized for computation. Similar to other workflow management systems, but optimized for interactive computational workloads.
- Like parallel arrays, dataframes, and lists that extend common interfaces like NumPy, Pandas, or Python iterators to **larger-than-memory** or distributed environments. These parallel collections run on top of dynamic task schedulers.
- Dynamic task **scheduling** optimized for computation. Similar to other workflow management systems, but optimized for interactive computational workloads.
- Like parallel arrays, dataframes, and lists that extend common interfaces like NumPy, Pandas, or Python iterators to **larger-than-memory** or distributed environments. These parallel collections run on top of dynamic task schedulers.
- `dask_ml package <https://ml.dask.org/>`_: Dask-ML provides scalable machine learning in Python using Dask alongside popular machine learning libraries like Scikit-Learn, XGBoost, and others.
678
677
- `Dask.distributed <https://distributed.dask.org/en/stable/>`_: Dask.distributed is a lightweight library for distributed computing in Python. It extends both the concurrent.futures and dask APIs to moderate sized clusters.
679
678
680
-
dask.arrays
681
-
^^^^^^^^^^^
679
+
``dask.arrays``
680
+
^^^^^^^^^^^^^^^
682
681
683
-
- A Dask array looks and feels a lot like a NumPy array.
682
+
- A Dask array looks and feels a lot like a **NumPy array**.
684
683
- However, a Dask array uses the so-called "lazy" execution mode, which allows one to
685
684
- build up complex, large calculations symbolically
686
685
- before turning them over the scheduler for execution.
@@ -721,25 +720,13 @@ Big file → split into chunks → parallel workers → results combined.
721
720
Polars package
722
721
..............
723
722
724
-
- ``polars`` is a Python package that presents itself as **Blazingly Fast DataFrame Library**
725
-
- Utilizes all available cores on your machine.
726
-
- Optimizes queries to reduce unneeded work/memory allocations.
727
-
- Handles datasets much larger than your available RAM.
728
-
- A consistent and predictable API.
729
-
- Adheres to a strict schema (data-types should be known before running the query).
730
-
731
-
.. admonition:: Key features
732
-
:class: dropdown
733
-
734
-
- Fast: Written from scratch in **Rust**
735
-
- I/O: First class **support for all common data storage** layers
736
-
- **Intuitive API**: Write your queries the way they were intended. Internally, there is a query optimizer.
737
-
- Out of Core: **streaming** without requiring all your data to be in memory at the same time. I.e. **chunking**
738
-
- **Parallel**: dividing the workload among the available CPU cores without any additional configuration.
739
-
- GPU Support: Optionally run queries on **NVIDIA GPUs**
740
-
- `Apache Arrow <https://arrow.apache.org/overview/>`_ support
723
+
`Polars <https://pola.rs/>`_ is a Python package that presents itself as **Blazingly Fast DataFrame Library**
724
+
- Utilizes all available cores on your machine.
725
+
- Optimizes queries to reduce unneeded work/memory allocations.
726
+
- Handles datasets much larger than your available RAM.
727
+
- A consistent and predictable API.
728
+
- Adheres to a strict schema (data-types should be known before running the query).
741
729
742
-
[`https://pola.rs/`](https://pola.rs/)
743
730
744
731
Exercises: Packages
745
732
-------------------
@@ -966,9 +953,9 @@ Set up the environment
966
953
But what happens if we use different chunk sizes?
967
954
Try out with different chunk sizes:
968
955
969
-
- What happens if the dask chunks=(20000,20000)
956
+
- What happens if the dask chunks=``(20000,20000)``
- Browse: https://docs.xarray.dev/en/v2024.11.0/getting-started-guide/why-xarray.html or change to more applicable version in drop-down menu to lower right.
979
+
- Browse: <https://docs.xarray.dev/en/v2024.11.0/getting-started-guide/why-xarray.html> or change to more applicable version in drop-down menu to lower right.
993
980
- find something interesting for you! Test some lines if you want to!
0 commit comments