[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6AFC24RGTER8Z787RT97759":3,"skill-same:01M6AFC24RGTER8Z787RT97759":100},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":26,"publishedAt":45,"linkOnly":46,"markdownContent":47,"markdownBody":48,"frontMatter":49,"refName":50,"commitSha":51,"skillDirectory":52,"forksCount":53,"repositoryHtmlUrl":54,"repositoryHomepageUrl":55,"ownerHtmlUrl":56,"ownerBlogUrl":57,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M6AFC24RGTER8Z787RT97759","dask",null,"Parallel\u002Fdistributed computing. Scale pandas\u002FNumPy beyond memory, parallel DataFrames\u002FArrays, multi-file processing, task graphs, for larger-than-RAM datasets and parallel workflows.","davila7\u002Fclaude-code-templates","davila7","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6216945?v=4","01M6ADEWWFPS191NFM0Y1EX1JH","Daniel Avila","01M6ADJHGM78PHQRD3XZTFDVKK",33332,"MIT","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fdask\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000013","分析与可视化","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[5,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],"arrays","for","parallel workflows","multi","processing","scale","dataframes","graphs","distributed computing","numpy","memory","task","datasets","parallel","file","pandas","distributed","workflows","2026-11-10 10:12:30",false,"---\nname: dask\ndescription: \"Parallel\u002Fdistributed computing. Scale pandas\u002FNumPy beyond memory, parallel DataFrames\u002FArrays, multi-file processing, task graphs, for larger-than-RAM datasets and parallel workflows.\"\n---\n\n# Dask\n\n## Overview\n\nDask is a Python library for parallel and distributed computing that enables three critical capabilities:\n- **Larger-than-memory execution** on single machines for data exceeding available RAM\n- **Parallel processing** for improved computational speed across multiple cores\n- **Distributed computation** supporting terabyte-scale datasets across multiple machines\n\nDask scales from laptops (processing ~100 GiB) to clusters (processing ~100 TiB) while maintaining familiar Python APIs.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Process datasets that exceed available RAM\n- Scale pandas or NumPy operations to larger datasets\n- Parallelize computations for performance improvements\n- Process multiple files efficiently (CSVs, Parquet, JSON, text logs)\n- Build custom parallel workflows with task dependencies\n- Distribute workloads across multiple cores or machines\n\n## Core Capabilities\n\nDask provides five main components, each suited to different use cases:\n\n### 1. DataFrames - Parallel Pandas Operations\n\n**Purpose**: Scale pandas operations to larger datasets through parallel processing.\n\n**When to Use**:\n- Tabular data exceeds available RAM\n- Need to process multiple CSV\u002FParquet files together\n- Pandas operations are slow and need parallelization\n- Scaling from pandas prototype to production\n\n**Reference Documentation**: For comprehensive guidance on Dask DataFrames, refer to `references\u002Fdataframes.md` which includes:\n- Reading data (single files, multiple files, glob patterns)\n- Common operations (filtering, groupby, joins, aggregations)\n- Custom operations with `map_partitions`\n- Performance optimization tips\n- Common patterns (ETL, time series, multi-file processing)\n\n**Quick Example**:\n```python\nimport dask.dataframe as dd\n\n# Read multiple files as single DataFrame\nddf = dd.read_csv('data\u002F2024-*.csv')\n\n# Operations are lazy until compute()\nfiltered = ddf[ddf['value'] > 100]\nresult = filtered.groupby('category').mean().compute()\n```\n\n**Key Points**:\n- Operations are lazy (build task graph) until `.compute()` called\n- Use `map_partitions` for efficient custom operations\n- Convert to DataFrame early when working with structured data from other sources\n\n### 2. Arrays - Parallel NumPy Operations\n\n**Purpose**: Extend NumPy capabilities to datasets larger than memory using blocked algorithms.\n\n**When to Use**:\n- Arrays exceed available RAM\n- NumPy operations need parallelization\n- Working with scientific datasets (HDF5, Zarr, NetCDF)\n- Need parallel linear algebra or array operations\n\n**Reference Documentation**: For comprehensive guidance on Dask Arrays, refer to `references\u002Farrays.md` which includes:\n- Creating arrays (from NumPy, random, from disk)\n- Chunking strategies and optimization\n- Common operations (arithmetic, reductions, linear algebra)\n- Custom operations with `map_blocks`\n- Integration with HDF5, Zarr, and XArray\n\n**Quick Example**:\n```python\nimport dask.array as da\n\n# Create large array with chunks\nx = da.random.random((100000, 100000), chunks=(10000, 10000))\n\n# Operations are lazy\ny = x + 100\nz = y.mean(axis=0)\n\n# Compute result\nresult = z.compute()\n```\n\n**Key Points**:\n- Chunk size is critical (aim for ~100 MB per chunk)\n- Operations work on chunks in parallel\n- Rechunk data when needed for efficient operations\n- Use `map_blocks` for operations not available in Dask\n\n### 3. Bags - Parallel Processing of Unstructured Data\n\n**Purpose**: Process unstructured or semi-structured data (text, JSON, logs) with functional operations.\n\n**When to Use**:\n- Processing text files, logs, or JSON records\n- Data cleaning and ETL before structured analysis\n- Working with Python objects that don't fit array\u002Fdataframe formats\n- Need memory-efficient streaming processing\n\n**Reference Documentation**: For comprehensive guidance on Dask Bags, refer to `references\u002Fbags.md` which includes:\n- Reading text and JSON files\n- Functional operations (map, filter, fold, groupby)\n- Converting to DataFrames\n- Common patterns (log analysis, JSON processing, text processing)\n- Performance considerations\n\n**Quick Example**:\n```python\nimport dask.bag as db\nimport json\n\n# Read and parse JSON files\nbag = db.read_text('logs\u002F*.json').map(json.loads)\n\n# Filter and transform\nvalid = bag.filter(lambda x: x['status'] == 'valid')\nprocessed = valid.map(lambda x: {'id': x['id'], 'value': x['value']})\n\n# Convert to DataFrame for analysis\nddf = processed.to_dataframe()\n```\n\n**Key Points**:\n- Use for initial data cleaning, then convert to DataFrame\u002FArray\n- Use `foldby` instead of `groupby` for better performance\n- Operations are streaming and memory-efficient\n- Convert to structured formats (DataFrame) for complex operations\n\n### 4. Futures - Task-Based Parallelization\n\n**Purpose**: Build custom parallel workflows with fine-grained control over task execution and dependencies.\n\n**When to Use**:\n- Building dynamic, evolving workflows\n- Need immediate task execution (not lazy)\n- Computations depend on runtime conditions\n- Implementing custom parallel algorithms\n- Need stateful computations\n\n**Reference Documentation**: For comprehensive guidance on Dask Futures, refer to `references\u002Ffutures.md` which includes:\n- Setting up distributed client\n- Submitting tasks and working with futures\n- Task dependencies and data movement\n- Advanced coordination (queues, locks, events, actors)\n- Common patterns (parameter sweeps, dynamic tasks, iterative algorithms)\n\n**Quick Example**:\n```python\nfrom dask.distributed import Client\n\nclient = Client()  # Create local cluster\n\n# Submit tasks (executes immediately)\ndef process(x):\n    return x ** 2\n\nfutures = client.map(process, range(100))\n\n# Gather results\nresults = client.gather(futures)\n\nclient.close()\n```\n\n**Key Points**:\n- Requires distributed client (even for single machine)\n- Tasks execute immediately when submitted\n- Pre-scatter large data to avoid repeated transfers\n- ~1ms overhead per task (not suitable for millions of tiny tasks)\n- Use actors for stateful workflows\n\n### 5. Schedulers - Execution Backends\n\n**Purpose**: Control how and where Dask tasks execute (threads, processes, distributed).\n\n**When to Choose Scheduler**:\n- **Threads** (default): NumPy\u002FPandas operations, GIL-releasing libraries, shared memory benefit\n- **Processes**: Pure Python code, text processing, GIL-bound operations\n- **Synchronous**: Debugging with pdb, profiling, understanding errors\n- **Distributed**: Need dashboard, multi-machine clusters, advanced features\n\n**Reference Documentation**: For comprehensive guidance on Dask Schedulers, refer to `references\u002Fschedulers.md` which includes:\n- Detailed scheduler descriptions and characteristics\n- Configuration methods (global, context manager, per-compute)\n- Performance considerations and overhead\n- Common patterns and troubleshooting\n- Thread configuration for optimal performance\n\n**Quick Example**:\n```python\nimport dask\nimport dask.dataframe as dd\n\n# Use threads for DataFrame (default, good for numeric)\nddf = dd.read_csv('data.csv')\nresult1 = ddf.mean().compute()  # Uses threads\n\n# Use processes for Python-heavy work\nimport dask.bag as db\nbag = db.read_text('logs\u002F*.txt')\nresult2 = bag.map(python_function).compute(scheduler='processes')\n\n# Use synchronous for debugging\ndask.config.set(scheduler='synchronous')\nresult3 = problematic_computation.compute()  # Can use pdb\n\n# Use distributed for monitoring and scaling\nfrom dask.distributed import Client\nclient = Client()\nresult4 = computation.compute()  # Uses distributed with dashboard\n```\n\n**Key Points**:\n- Threads: Lowest overhead (~10 µs\u002Ftask), best for numeric work\n- Processes: Avoids GIL (~10 ms\u002Ftask), best for Python work\n- Distributed: Monitoring dashboard (~1 ms\u002Ftask), scales to clusters\n- Can switch schedulers per computation or globally\n\n## Best Practices\n\nFor comprehensive performance optimization guidance, memory management strategies, and common pitfalls to avoid, refer to `references\u002Fbest-practices.md`. Key principles include:\n\n### Start with Simpler Solutions\nBefore using Dask, explore:\n- Better algorithms\n- Efficient file formats (Parquet instead of CSV)\n- Compiled code (Numba, Cython)\n- Data sampling\n\n### Critical Performance Rules\n\n**1. Don't Load Data Locally Then Hand to Dask**\n```python\n# Wrong: Loads all data in memory first\nimport pandas as pd\ndf = pd.read_csv('large.csv')\nddf = dd.from_pandas(df, npartitions=10)\n\n# Correct: Let Dask handle loading\nimport dask.dataframe as dd\nddf = dd.read_csv('large.csv')\n```\n\n**2. Avoid Repeated compute() Calls**\n```python\n# Wrong: Each compute is separate\nfor item in items:\n    result = dask_computation(item).compute()\n\n# Correct: Single compute for all\ncomputations = [dask_computation(item) for item in items]\nresults = dask.compute(*computations)\n```\n\n**3. Don't Build Excessively Large Task Graphs**\n- Increase chunk sizes if millions of tasks\n- Use `map_partitions`\u002F`map_blocks` to fuse operations\n- Check task graph size: `len(ddf.__dask_graph__())`\n\n**4. Choose Appropriate Chunk Sizes**\n- Target: ~100 MB per chunk (or 10 chunks per core in worker memory)\n- Too large: Memory overflow\n- Too small: Scheduling overhead\n\n**5. Use the Dashboard**\n```python\nfrom dask.distributed import Client\nclient = Client()\nprint(client.dashboard_link)  # Monitor performance, identify bottlenecks\n```\n\n## Common Workflow Patterns\n\n### ETL Pipeline\n```python\nimport dask.dataframe as dd\n\n# Extract: Read data\nddf = dd.read_csv('raw_data\u002F*.csv')\n\n# Transform: Clean and process\nddf = ddf[ddf['status'] == 'valid']\nddf['amount'] = ddf['amount'].astype('float64')\nddf = ddf.dropna(subset=['important_col'])\n\n# Load: Aggregate and save\nsummary = ddf.groupby('category').agg({'amount': ['sum', 'mean']})\nsummary.to_parquet('output\u002Fsummary.parquet')\n```\n\n### Unstructured to Structured Pipeline\n```python\nimport dask.bag as db\nimport json\n\n# Start with Bag for unstructured data\nbag = db.read_text('logs\u002F*.json').map(json.loads)\nbag = bag.filter(lambda x: x['status'] == 'valid')\n\n# Convert to DataFrame for structured analysis\nddf = bag.to_dataframe()\nresult = ddf.groupby('category').mean().compute()\n```\n\n### Large-Scale Array Computation\n```python\nimport dask.array as da\n\n# Load or create large array\nx = da.from_zarr('large_dataset.zarr')\n\n# Process in chunks\nnormalized = (x - x.mean()) \u002F x.std()\n\n# Save result\nda.to_zarr(normalized, 'normalized.zarr')\n```\n\n### Custom Parallel Workflow\n```python\nfrom dask.distributed import Client\n\nclient = Client()\n\n# Scatter large dataset once\ndata = client.scatter(large_dataset)\n\n# Process in parallel with dependencies\nfutures = []\nfor param in parameters:\n    future = client.submit(process, data, param)\n    futures.append(future)\n\n# Gather results\nresults = client.gather(futures)\n```\n\n## Selecting the Right Component\n\nUse this decision guide to choose the appropriate Dask component:\n\n**Data Type**:\n- Tabular data → **DataFrames**\n- Numeric arrays → **Arrays**\n- Text\u002FJSON\u002Flogs → **Bags** (then convert to DataFrame)\n- Custom Python objects → **Bags** or **Futures**\n\n**Operation Type**:\n- Standard pandas operations → **DataFrames**\n- Standard NumPy operations → **Arrays**\n- Custom parallel tasks → **Futures**\n- Text processing\u002FETL → **Bags**\n\n**Control Level**:\n- High-level, automatic → **DataFrames\u002FArrays**\n- Low-level, manual → **Futures**\n\n**Workflow Type**:\n- Static computation graph → **DataFrames\u002FArrays\u002FBags**\n- Dynamic, evolving → **Futures**\n\n## Integration Considerations\n\n### File Formats\n- **Efficient**: Parquet, HDF5, Zarr (columnar, compressed, parallel-friendly)\n- **Compatible but slower**: CSV (use for initial ingestion only)\n- **For Arrays**: HDF5, Zarr, NetCDF\n\n### Conversion Between Collections\n```python\n# Bag → DataFrame\nddf = bag.to_dataframe()\n\n# DataFrame → Array (for numeric data)\narr = ddf.to_dask_array(lengths=True)\n\n# Array → DataFrame\nddf = dd.from_dask_array(arr, columns=['col1', 'col2'])\n```\n\n### With Other Libraries\n- **XArray**: Wraps Dask arrays with labeled dimensions (geospatial, imaging)\n- **Dask-ML**: Machine learning with scikit-learn compatible APIs\n- **Distributed**: Advanced cluster management and monitoring\n\n## Debugging and Development\n\n### Iterative Development Workflow\n\n1. **Test on small data with synchronous scheduler**:\n```python\ndask.config.set(scheduler='synchronous')\nresult = computation.compute()  # Can use pdb, easy debugging\n```\n\n2. **Validate with threads on sample**:\n```python\nsample = ddf.head(1000)  # Small sample\n# Test logic, then scale to full dataset\n```\n\n3. **Scale with distributed for monitoring**:\n```python\nfrom dask.distributed import Client\nclient = Client()\nprint(client.dashboard_link)  # Monitor performance\nresult = computation.compute()\n```\n\n### Common Issues\n\n**Memory Errors**:\n- Decrease chunk sizes\n- Use `persist()` strategically and delete when done\n- Check for memory leaks in custom functions\n\n**Slow Start**:\n- Task graph too large (increase chunk sizes)\n- Use `map_partitions` or `map_blocks` to reduce tasks\n\n**Poor Parallelization**:\n- Chunks too large (increase number of partitions)\n- Using threads with Python code (switch to processes)\n- Data dependencies preventing parallelism\n\n## Reference Files\n\nAll reference documentation files can be read as needed for detailed information:\n\n- `references\u002Fdataframes.md` - Complete Dask DataFrame guide\n- `references\u002Farrays.md` - Complete Dask Array guide\n- `references\u002Fbags.md` - Complete Dask Bag guide\n- `references\u002Ffutures.md` - Complete Dask Futures and distributed computing guide\n- `references\u002Fschedulers.md` - Complete scheduler selection and configuration guide\n- `references\u002Fbest-practices.md` - Comprehensive performance optimization and troubleshooting\n\nLoad these files when users need detailed information about specific Dask components, operations, or patterns beyond the quick guidance provided here.\n","# Dask\n\n## Overview\n\nDask is a Python library for parallel and distributed computing that enables three critical capabilities:\n- **Larger-than-memory execution** on single machines for data exceeding available RAM\n- **Parallel processing** for improved computational speed across multiple cores\n- **Distributed computation** supporting terabyte-scale datasets across multiple machines\n\nDask scales from laptops (processing ~100 GiB) to clusters (processing ~100 TiB) while maintaining familiar Python APIs.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Process datasets that exceed available RAM\n- Scale pandas or NumPy operations to larger datasets\n- Parallelize computations for performance improvements\n- Process multiple files efficiently (CSVs, Parquet, JSON, text logs)\n- Build custom parallel workflows with task dependencies\n- Distribute workloads across multiple cores or machines\n\n## Core Capabilities\n\nDask provides five main components, each suited to different use cases:\n\n### 1. DataFrames - Parallel Pandas Operations\n\n**Purpose**: Scale pandas operations to larger datasets through parallel processing.\n\n**When to Use**:\n- Tabular data exceeds available RAM\n- Need to process multiple CSV\u002FParquet files together\n- Pandas operations are slow and need parallelization\n- Scaling from pandas prototype to production\n\n**Reference Documentation**: For comprehensive guidance on Dask DataFrames, refer to `references\u002Fdataframes.md` which includes:\n- Reading data (single files, multiple files, glob patterns)\n- Common operations (filtering, groupby, joins, aggregations)\n- Custom operations with `map_partitions`\n- Performance optimization tips\n- Common patterns (ETL, time series, multi-file processing)\n\n**Quick Example**:\n```python\nimport dask.dataframe as dd\n\n# Read multiple files as single DataFrame\nddf = dd.read_csv('data\u002F2024-*.csv')\n\n# Operations are lazy until compute()\nfiltered = ddf[ddf['value'] > 100]\nresult = filtered.groupby('category').mean().compute()\n```\n\n**Key Points**:\n- Operations are lazy (build task graph) until `.compute()` called\n- Use `map_partitions` for efficient custom operations\n- Convert to DataFrame early when working with structured data from other sources\n\n### 2. Arrays - Parallel NumPy Operations\n\n**Purpose**: Extend NumPy capabilities to datasets larger than memory using blocked algorithms.\n\n**When to Use**:\n- Arrays exceed available RAM\n- NumPy operations need parallelization\n- Working with scientific datasets (HDF5, Zarr, NetCDF)\n- Need parallel linear algebra or array operations\n\n**Reference Documentation**: For comprehensive guidance on Dask Arrays, refer to `references\u002Farrays.md` which includes:\n- Creating arrays (from NumPy, random, from disk)\n- Chunking strategies and optimization\n- Common operations (arithmetic, reductions, linear algebra)\n- Custom operations with `map_blocks`\n- Integration with HDF5, Zarr, and XArray\n\n**Quick Example**:\n```python\nimport dask.array as da\n\n# Create large array with chunks\nx = da.random.random((100000, 100000), chunks=(10000, 10000))\n\n# Operations are lazy\ny = x + 100\nz = y.mean(axis=0)\n\n# Compute result\nresult = z.compute()\n```\n\n**Key Points**:\n- Chunk size is critical (aim for ~100 MB per chunk)\n- Operations work on chunks in parallel\n- Rechunk data when needed for efficient operations\n- Use `map_blocks` for operations not available in Dask\n\n### 3. Bags - Parallel Processing of Unstructured Data\n\n**Purpose**: Process unstructured or semi-structured data (text, JSON, logs) with functional operations.\n\n**When to Use**:\n- Processing text files, logs, or JSON records\n- Data cleaning and ETL before structured analysis\n- Working with Python objects that don't fit array\u002Fdataframe formats\n- Need memory-efficient streaming processing\n\n**Reference Documentation**: For comprehensive guidance on Dask Bags, refer to `references\u002Fbags.md` which includes:\n- Reading text and JSON files\n- Functional operations (map, filter, fold, groupby)\n- Converting to DataFrames\n- Common patterns (log analysis, JSON processing, text processing)\n- Performance considerations\n\n**Quick Example**:\n```python\nimport dask.bag as db\nimport json\n\n# Read and parse JSON files\nbag = db.read_text('logs\u002F*.json').map(json.loads)\n\n# Filter and transform\nvalid = bag.filter(lambda x: x['status'] == 'valid')\nprocessed = valid.map(lambda x: {'id': x['id'], 'value': x['value']})\n\n# Convert to DataFrame for analysis\nddf = processed.to_dataframe()\n```\n\n**Key Points**:\n- Use for initial data cleaning, then convert to DataFrame\u002FArray\n- Use `foldby` instead of `groupby` for better performance\n- Operations are streaming and memory-efficient\n- Convert to structured formats (DataFrame) for complex operations\n\n### 4. Futures - Task-Based Parallelization\n\n**Purpose**: Build custom parallel workflows with fine-grained control over task execution and dependencies.\n\n**When to Use**:\n- Building dynamic, evolving workflows\n- Need immediate task execution (not lazy)\n- Computations depend on runtime conditions\n- Implementing custom parallel algorithms\n- Need stateful computations\n\n**Reference Documentation**: For comprehensive guidance on Dask Futures, refer to `references\u002Ffutures.md` which includes:\n- Setting up distributed client\n- Submitting tasks and working with futures\n- Task dependencies and data movement\n- Advanced coordination (queues, locks, events, actors)\n- Common patterns (parameter sweeps, dynamic tasks, iterative algorithms)\n\n**Quick Example**:\n```python\nfrom dask.distributed import Client\n\nclient = Client()  # Create local cluster\n\n# Submit tasks (executes immediately)\ndef process(x):\n    return x ** 2\n\nfutures = client.map(process, range(100))\n\n# Gather results\nresults = client.gather(futures)\n\nclient.close()\n```\n\n**Key Points**:\n- Requires distributed client (even for single machine)\n- Tasks execute immediately when submitted\n- Pre-scatter large data to avoid repeated transfers\n- ~1ms overhead per task (not suitable for millions of tiny tasks)\n- Use actors for stateful workflows\n\n### 5. Schedulers - Execution Backends\n\n**Purpose**: Control how and where Dask tasks execute (threads, processes, distributed).\n\n**When to Choose Scheduler**:\n- **Threads** (default): NumPy\u002FPandas operations, GIL-releasing libraries, shared memory benefit\n- **Processes**: Pure Python code, text processing, GIL-bound operations\n- **Synchronous**: Debugging with pdb, profiling, understanding errors\n- **Distributed**: Need dashboard, multi-machine clusters, advanced features\n\n**Reference Documentation**: For comprehensive guidance on Dask Schedulers, refer to `references\u002Fschedulers.md` which includes:\n- Detailed scheduler descriptions and characteristics\n- Configuration methods (global, context manager, per-compute)\n- Performance considerations and overhead\n- Common patterns and troubleshooting\n- Thread configuration for optimal performance\n\n**Quick Example**:\n```python\nimport dask\nimport dask.dataframe as dd\n\n# Use threads for DataFrame (default, good for numeric)\nddf = dd.read_csv('data.csv')\nresult1 = ddf.mean().compute()  # Uses threads\n\n# Use processes for Python-heavy work\nimport dask.bag as db\nbag = db.read_text('logs\u002F*.txt')\nresult2 = bag.map(python_function).compute(scheduler='processes')\n\n# Use synchronous for debugging\ndask.config.set(scheduler='synchronous')\nresult3 = problematic_computation.compute()  # Can use pdb\n\n# Use distributed for monitoring and scaling\nfrom dask.distributed import Client\nclient = Client()\nresult4 = computation.compute()  # Uses distributed with dashboard\n```\n\n**Key Points**:\n- Threads: Lowest overhead (~10 µs\u002Ftask), best for numeric work\n- Processes: Avoids GIL (~10 ms\u002Ftask), best for Python work\n- Distributed: Monitoring dashboard (~1 ms\u002Ftask), scales to clusters\n- Can switch schedulers per computation or globally\n\n## Best Practices\n\nFor comprehensive performance optimization guidance, memory management strategies, and common pitfalls to avoid, refer to `references\u002Fbest-practices.md`. Key principles include:\n\n### Start with Simpler Solutions\nBefore using Dask, explore:\n- Better algorithms\n- Efficient file formats (Parquet instead of CSV)\n- Compiled code (Numba, Cython)\n- Data sampling\n\n### Critical Performance Rules\n\n**1. Don't Load Data Locally Then Hand to Dask**\n```python\n# Wrong: Loads all data in memory first\nimport pandas as pd\ndf = pd.read_csv('large.csv')\nddf = dd.from_pandas(df, npartitions=10)\n\n# Correct: Let Dask handle loading\nimport dask.dataframe as dd\nddf = dd.read_csv('large.csv')\n```\n\n**2. Avoid Repeated compute() Calls**\n```python\n# Wrong: Each compute is separate\nfor item in items:\n    result = dask_computation(item).compute()\n\n# Correct: Single compute for all\ncomputations = [dask_computation(item) for item in items]\nresults = dask.compute(*computations)\n```\n\n**3. Don't Build Excessively Large Task Graphs**\n- Increase chunk sizes if millions of tasks\n- Use `map_partitions`\u002F`map_blocks` to fuse operations\n- Check task graph size: `len(ddf.__dask_graph__())`\n\n**4. Choose Appropriate Chunk Sizes**\n- Target: ~100 MB per chunk (or 10 chunks per core in worker memory)\n- Too large: Memory overflow\n- Too small: Scheduling overhead\n\n**5. Use the Dashboard**\n```python\nfrom dask.distributed import Client\nclient = Client()\nprint(client.dashboard_link)  # Monitor performance, identify bottlenecks\n```\n\n## Common Workflow Patterns\n\n### ETL Pipeline\n```python\nimport dask.dataframe as dd\n\n# Extract: Read data\nddf = dd.read_csv('raw_data\u002F*.csv')\n\n# Transform: Clean and process\nddf = ddf[ddf['status'] == 'valid']\nddf['amount'] = ddf['amount'].astype('float64')\nddf = ddf.dropna(subset=['important_col'])\n\n# Load: Aggregate and save\nsummary = ddf.groupby('category').agg({'amount': ['sum', 'mean']})\nsummary.to_parquet('output\u002Fsummary.parquet')\n```\n\n### Unstructured to Structured Pipeline\n```python\nimport dask.bag as db\nimport json\n\n# Start with Bag for unstructured data\nbag = db.read_text('logs\u002F*.json').map(json.loads)\nbag = bag.filter(lambda x: x['status'] == 'valid')\n\n# Convert to DataFrame for structured analysis\nddf = bag.to_dataframe()\nresult = ddf.groupby('category').mean().compute()\n```\n\n### Large-Scale Array Computation\n```python\nimport dask.array as da\n\n# Load or create large array\nx = da.from_zarr('large_dataset.zarr')\n\n# Process in chunks\nnormalized = (x - x.mean()) \u002F x.std()\n\n# Save result\nda.to_zarr(normalized, 'normalized.zarr')\n```\n\n### Custom Parallel Workflow\n```python\nfrom dask.distributed import Client\n\nclient = Client()\n\n# Scatter large dataset once\ndata = client.scatter(large_dataset)\n\n# Process in parallel with dependencies\nfutures = []\nfor param in parameters:\n    future = client.submit(process, data, param)\n    futures.append(future)\n\n# Gather results\nresults = client.gather(futures)\n```\n\n## Selecting the Right Component\n\nUse this decision guide to choose the appropriate Dask component:\n\n**Data Type**:\n- Tabular data → **DataFrames**\n- Numeric arrays → **Arrays**\n- Text\u002FJSON\u002Flogs → **Bags** (then convert to DataFrame)\n- Custom Python objects → **Bags** or **Futures**\n\n**Operation Type**:\n- Standard pandas operations → **DataFrames**\n- Standard NumPy operations → **Arrays**\n- Custom parallel tasks → **Futures**\n- Text processing\u002FETL → **Bags**\n\n**Control Level**:\n- High-level, automatic → **DataFrames\u002FArrays**\n- Low-level, manual → **Futures**\n\n**Workflow Type**:\n- Static computation graph → **DataFrames\u002FArrays\u002FBags**\n- Dynamic, evolving → **Futures**\n\n## Integration Considerations\n\n### File Formats\n- **Efficient**: Parquet, HDF5, Zarr (columnar, compressed, parallel-friendly)\n- **Compatible but slower**: CSV (use for initial ingestion only)\n- **For Arrays**: HDF5, Zarr, NetCDF\n\n### Conversion Between Collections\n```python\n# Bag → DataFrame\nddf = bag.to_dataframe()\n\n# DataFrame → Array (for numeric data)\narr = ddf.to_dask_array(lengths=True)\n\n# Array → DataFrame\nddf = dd.from_dask_array(arr, columns=['col1', 'col2'])\n```\n\n### With Other Libraries\n- **XArray**: Wraps Dask arrays with labeled dimensions (geospatial, imaging)\n- **Dask-ML**: Machine learning with scikit-learn compatible APIs\n- **Distributed**: Advanced cluster management and monitoring\n\n## Debugging and Development\n\n### Iterative Development Workflow\n\n1. **Test on small data with synchronous scheduler**:\n```python\ndask.config.set(scheduler='synchronous')\nresult = computation.compute()  # Can use pdb, easy debugging\n```\n\n2. **Validate with threads on sample**:\n```python\nsample = ddf.head(1000)  # Small sample\n# Test logic, then scale to full dataset\n```\n\n3. **Scale with distributed for monitoring**:\n```python\nfrom dask.distributed import Client\nclient = Client()\nprint(client.dashboard_link)  # Monitor performance\nresult = computation.compute()\n```\n\n### Common Issues\n\n**Memory Errors**:\n- Decrease chunk sizes\n- Use `persist()` strategically and delete when done\n- Check for memory leaks in custom functions\n\n**Slow Start**:\n- Task graph too large (increase chunk sizes)\n- Use `map_partitions` or `map_blocks` to reduce tasks\n\n**Poor Parallelization**:\n- Chunks too large (increase number of partitions)\n- Using threads with Python code (switch to processes)\n- Data dependencies preventing parallelism\n\n## Reference Files\n\nAll reference documentation files can be read as needed for detailed information:\n\n- `references\u002Fdataframes.md` - Complete Dask DataFrame guide\n- `references\u002Farrays.md` - Complete Dask Array guide\n- `references\u002Fbags.md` - Complete Dask Bag guide\n- `references\u002Ffutures.md` - Complete Dask Futures and distributed computing guide\n- `references\u002Fschedulers.md` - Complete scheduler selection and configuration guide\n- `references\u002Fbest-practices.md` - Comprehensive performance optimization and troubleshooting\n\nLoad these files when users need detailed information about specific Dask components, operations, or patterns beyond the quick guidance provided here.\n",{"name":5,"description":7},"main","2b749c82b5d11fac39d9a6e021ce3f5b8a541bd1","cli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fdask",3911,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates","https:\u002F\u002Faitmpl.com","https:\u002F\u002Fgithub.com\u002Fdavila7","https:\u002F\u002Fdanielavila.me","Building AI dev tools with LLMs","2026-11-11 21:38:31",{"source":8,"skillName":5,"commands":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add davila7\u002Fclaude-code-templates --skill dask",{"tool":66,"command":67},"bunx","bunx skills add davila7\u002Fclaude-code-templates --skill dask",{"tool":69,"command":70},"pnpm","pnpm dlx skills add davila7\u002Fclaude-code-templates --skill dask","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fdask\u002FSKILL.md",true,[74,80,84,88,92,96],{"path":75,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":79},"references\u002Farrays.md","REFERENCE","参考文档",11649,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fdask\u002Freferences\u002Farrays.md",{"path":81,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Fbags.md",10869,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fdask\u002Freferences\u002Fbags.md",{"path":85,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":86,"sourceHtmlUrl":87},"references\u002Fbest-practices.md",7317,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fdask\u002Freferences\u002Fbest-practices.md",{"path":89,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":90,"sourceHtmlUrl":91},"references\u002Fdataframes.md",8778,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fdask\u002Freferences\u002Fdataframes.md",{"path":93,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":94,"sourceHtmlUrl":95},"references\u002Ffutures.md",12051,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fdask\u002Freferences\u002Ffutures.md",{"path":97,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":98,"sourceHtmlUrl":99},"references\u002Fschedulers.md",11313,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fdask\u002Freferences\u002Fschedulers.md",[101,128,155,188,222,246],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":108,"publishedAt":45},"01M70NHBTQ8BV0A2SCAZXEPHCX","wealthville-pool-scoring","Score DeFi liquidity pools before providing liquidity. Returns a 0-100 pool score and an Enter\u002FHold\u002FExit\u002FReduce\u002FAvoid verdict with calibrated confidence for ~68,800 Solana pools and 575 EVM pools, plus a public miss-inclusive track record. Use when asked whether a pool is worth LPing into, which pools look best right now, or how accurate the scores have actually been.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fweb-data\u002Fwealthville-pool-scoring\u002FSKILL.md",[107],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[109,110,111,112,113,28,114,115,116,117,118,119,120,121,122,123,124,125,126,127],"scoring","pool","wealthville pool scoring","liquidity","which","exit","now","use","when","reduce","with","record","track","verdict","evm","solana","how","public","look",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":135,"publishedAt":45},"01M70MB6VR8ERJ4EM8D5KHBMEV","technical-debt-auditor","Scans a codebase and produces a quantified technical debt report with a prioritized remediation plan. Analyzes dead code, TODO\u002FFIXME\u002FHACK markers, dependency staleness, complexity hotspots, code duplication signals, test coverage gaps, unused exports, and outdated patterns. Use this skill when the user asks to audit their codebase for tech debt, wants a health check of their code quality, says things like \"where should I focus refactoring\", \"find code smells\", \"audit my codebase\", \"what technical debt do we have\", \"prioritize cleanup work\", or asks about code quality metrics. Also trigger when the user mentions \"code rot\", \"legacy cleanup\", \"refactoring priorities\", or wants to understand the overall health of a project before a major effort. Trigger even if the user doesn't say \"technical debt\" explicitly — any request to systematically assess code quality and identify improvement priorities belongs here.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdevelopment\u002Ftechnical-debt-auditor\u002FSKILL.md",[134],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[136,137,138,139,140,141,142,143,144,145,146,117,147,148,149,150,151,152,153,154],"technical debt","debt","technical","technical debt auditor","auditor","coverage","complexity","markers","project","cleanup","unused","code","todo","work","plan","focus","signals","audit","dependency",{"skillNo":156,"name":157,"nameZh":6,"description":158,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":159,"categories":160,"keywords":170,"publishedAt":45},"01M70KPYH9QNHCNME5GJQGE22K","readonly-sql-guard","Make an agent's database access provably read-only. Use when an agent runs caller-supplied SQL against a production\u002FERP\u002Fanalytics database (a \"query\" MCP tool, text-to-SQL, an admin console), or when reviewing DB-access code for write\u002FDDL\u002Fside-effect\u002Ftransaction-escape risks. Checks what a statement CALLS, not just its shape.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdatabase\u002Freadonly-sql-guard\u002FSKILL.md",[161,164,165],{"categoryNo":162,"categoryName":163,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":166,"categoryName":167,"taxonomyType":168,"taxonomyTypeDesc":169},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[171,172,173,174,175,176,177,28,178,179,180,181,182,183,184,116,185,186,117,187],"readonly","guard","sql guard","sql","readonly sql guard","erp","effect","read-only","db","just","tool","calls","only","MCP","access","database","query",{"skillNo":189,"name":190,"nameZh":6,"description":191,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":192,"licenseFileUrl":193,"sourceHtmlUrl":194,"categories":195,"keywords":199,"publishedAt":45},"01M6AFY6F7CC2BBZP1QD6VTNVC","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FSKILL.md",[196],{"categoryNo":197,"categoryName":198,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",[200,201,202,203,204,205,206,207,208,209,210,211,212,41,213,214,215,216,217,218,219,220,28,221],"artifacts builder","web","web artifacts builder","artifacts","builder","state","routing","state management","component","css","frontend","ui","Tools","components","shadcn","react","Tailwind","suite","jsx","html","single-file","ui components",{"skillNo":223,"name":224,"nameZh":6,"description":225,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":192,"licenseFileUrl":226,"sourceHtmlUrl":227,"categories":228,"keywords":233,"publishedAt":45},"01M6AFWF33SFV9Z3SF4PEEE4BF","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FSKILL.md",[229,232],{"categoryNo":230,"categoryName":231,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":197,"categoryName":198,"taxonomyType":21,"taxonomyTypeDesc":22},[234,235,236,237,238,201,239,210,211,240,241,242,243,28,244,119,245],"webapp testing","testing","webapp","browser","playwright","applications","debugging","toolkit","logs","screenshots","local","behavior",{"skillNo":247,"name":248,"nameZh":6,"description":249,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":192,"licenseFileUrl":250,"sourceHtmlUrl":251,"categories":252,"keywords":260,"publishedAt":45},"01M6AF67Q67JJJ5V51JR2P52KA","discernment-nudge","After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fdiscernment-nudge\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fdiscernment-nudge\u002FSKILL.md",[253,256,257],{"categoryNo":254,"categoryName":255,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":258,"categoryName":259,"taxonomyType":168,"taxonomyTypeDesc":169},"01JBSEEDCAT000000000000036","内容创作者",[261,262,263,264,265,266,267,268,203,269,41,147,270,271,272,273,274,183,275,117,276,277,278,279,280,125,281],"discernment nudge","nudge","interpretation","help","run","reasoning","data","writing","lookup","content","review","conversation","short","up","invoke","you","analysis","claims","argument","assemble","recommendations"]