help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
dask-parallel
/
notebooks
RSK World
dask-parallel
Parallel and distributed computing with Dask
notebooks
  • 01_dask_arrays.ipynb4.2 KB
  • 02_dask_dataframes.ipynb5 KB
  • 03_delayed_computations.ipynb5.2 KB
  • 04_distributed_computing.ipynb4.8 KB
  • 05_task_scheduling.ipynb5.4 KB
  • 06_dask_bags.ipynb5.3 KB
  • 07_advanced_dataframes.ipynb6.7 KB
  • 08_dask_ml.ipynb7.2 KB
01_dask_arrays.ipynb
notebooks/01_dask_arrays.ipynb
Raw Download
Find: Go to:
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Dask Arrays - Parallel Array Computing\n",
        "\n",
        "<!--\n",
        "Project: Dask Parallel Computing\n",
        "Author: Molla Samser\n",
        "Designer & Tester: Rima Khatun\n",
        "Website: https://rskworld.in\n",
        "Email: help@rskworld.in, support@rskworld.in\n",
        "Phone: +91 93305 39277\n",
        "-->\n",
        "\n",
        "This notebook demonstrates how to use Dask arrays for parallel computing with large arrays.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import dask.array as da\n",
        "import numpy as np\n",
        "import time\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "print(\"Dask Arrays Demo\")\n",
        "print(\"=\" * 50)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Creating Large Arrays\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Create a large Dask array (chunked)\n",
        "# This array is too large to fit in memory, but Dask handles it efficiently\n",
        "large_array = da.random.random((10000, 10000), chunks=(1000, 1000))\n",
        "\n",
        "print(f\"Array shape: {large_array.shape}\")\n",
        "print(f\"Chunk size: {large_array.chunksize}\")\n",
        "print(f\"Number of chunks: {large_array.numblocks}\")\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Array Operations\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Perform operations on the array\n",
        "# Operations are lazy - they don't execute until compute() is called\n",
        "result = (large_array + 1) * 2\n",
        "sum_result = result.sum()\n",
        "\n",
        "print(\"Computing result...\")\n",
        "start_time = time.time()\n",
        "final_sum = sum_result.compute()\n",
        "end_time = time.time()\n",
        "\n",
        "print(f\"Sum result: {final_sum}\")\n",
        "print(f\"Computation time: {end_time - start_time:.2f} seconds\")\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Comparison with NumPy\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Compare with NumPy for smaller arrays\n",
        "size = 5000\n",
        "\n",
        "# NumPy (in-memory)\n",
        "start = time.time()\n",
        "np_array = np.random.random((size, size))\n",
        "np_result = (np_array + 1) * 2\n",
        "np_sum = np_result.sum()\n",
        "numpy_time = time.time() - start\n",
        "\n",
        "# Dask (chunked)\n",
        "start = time.time()\n",
        "dask_array = da.random.random((size, size), chunks=(1000, 1000))\n",
        "dask_result = (dask_array + 1) * 2\n",
        "dask_sum = dask_result.sum().compute()\n",
        "dask_time = time.time() - start\n",
        "\n",
        "print(f\"NumPy time: {numpy_time:.2f} seconds\")\n",
        "print(f\"Dask time: {dask_time:.2f} seconds\")\n",
        "print(f\"Results match: {np.isclose(np_sum, dask_sum)}\")\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Array Visualization\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Visualize a smaller chunk of the array\n",
        "sample = large_array[:100, :100].compute()\n",
        "\n",
        "plt.figure(figsize=(8, 6))\n",
        "plt.imshow(sample, cmap='viridis')\n",
        "plt.colorbar()\n",
        "plt.title('Sample from Large Dask Array')\n",
        "plt.show()\n"
      ]
    }
  ],
  "metadata": {
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}
152 lines•4.2 KB
json

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer