$npx -y skills add langchain-ai/deepagents --skill cudf-analyticsUse for GPU-accelerated data analysis on datasets, CSVs, or tabular data using NVIDIA cuDF. Triggers when tasks involve groupby aggregations, statistical summaries, anomaly detection, or large-scale data profiling.
| 1 | # cuDF Analytics Skill |
| 2 | |
| 3 | GPU-accelerated data analysis using NVIDIA RAPIDS cuDF. cuDF provides a pandas-like API that runs on NVIDIA GPUs, enabling massive speedups on large datasets. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when: |
| 8 | - Analyzing CSV files, datasets, or tabular data |
| 9 | - Computing statistical summaries (mean, median, std, quartiles) |
| 10 | - Performing groupby aggregations |
| 11 | - Detecting anomalies or outliers in data |
| 12 | - Profiling datasets with millions of rows |
| 13 | - Computing correlation matrices |
| 14 | |
| 15 | ## Initialization (REQUIRED) |
| 16 | |
| 17 | Always start every script with this boilerplate. It tests actual GPU operations, not just import. |
| 18 | |
| 19 | ```python |
| 20 | import pandas as pd |
| 21 | |
| 22 | try: |
| 23 | import cudf |
| 24 | # Smoke-test: verify GPU compute AND host transfer both work |
| 25 | _test = cudf.Series([1, 2, 3]) |
| 26 | assert _test.sum() == 6 |
| 27 | assert _test.to_pandas().tolist() == [1, 2, 3] |
| 28 | GPU = True |
| 29 | except Exception as e: |
| 30 | print(f"[GPU] cudf unavailable, falling back to pandas: {e}") |
| 31 | GPU = False |
| 32 | |
| 33 | def read_csv(path): |
| 34 | return cudf.read_csv(path) if GPU else pd.read_csv(path) |
| 35 | |
| 36 | def to_pd(df): |
| 37 | """Convert cuDF DataFrame/Series to pandas. Use this instead of .to_pandas() directly.""" |
| 38 | if not GPU: |
| 39 | return df |
| 40 | try: |
| 41 | return df.to_pandas() |
| 42 | except Exception as e: |
| 43 | print(f"[GPU] .to_pandas() failed, using Arrow fallback: {e}") |
| 44 | return df.to_arrow().to_pandas() |
| 45 | ``` |
| 46 | |
| 47 | ## Quick Reference |
| 48 | |
| 49 | cuDF mirrors the pandas API. Common operations: |
| 50 | |
| 51 | ### Read Data |
| 52 | ```python |
| 53 | df = read_csv("data.csv") |
| 54 | ``` |
| 55 | |
| 56 | ### Statistical Summary |
| 57 | ```python |
| 58 | # Use to_pd() when you need pandas output |
| 59 | summary = to_pd(df[["value", "score"]].describe()) |
| 60 | |
| 61 | # Scalar values work directly with float() |
| 62 | mean_val = float(df["value"].mean()) |
| 63 | q1 = float(df["value"].quantile(0.25)) |
| 64 | |
| 65 | # Correlation |
| 66 | corr = float(df["value"].corr(df["score"])) |
| 67 | ``` |
| 68 | |
| 69 | ### Groupby Aggregation |
| 70 | ```python |
| 71 | result = df.groupby("category").agg({ |
| 72 | "revenue": ["sum", "mean", "count"], |
| 73 | "quantity": ["sum", "mean"], |
| 74 | }) |
| 75 | result_pd = to_pd(result) |
| 76 | ``` |
| 77 | |
| 78 | ### Anomaly Detection (IQR Method) |
| 79 | ```python |
| 80 | col = "value" |
| 81 | Q1 = float(df[col].quantile(0.25)) |
| 82 | Q3 = float(df[col].quantile(0.75)) |
| 83 | IQR = Q3 - Q1 |
| 84 | lower = Q1 - 1.5 * IQR |
| 85 | upper = Q3 + 1.5 * IQR |
| 86 | outliers = to_pd(df[(df[col] < lower) | (df[col] > upper)]) |
| 87 | ``` |
| 88 | |
| 89 | ### Anomaly Detection (Z-Score Method) |
| 90 | ```python |
| 91 | mean = float(df[col].mean()) |
| 92 | std = float(df[col].std()) |
| 93 | df["z_score"] = (df[col] - mean) / std |
| 94 | anomalies = to_pd(df[df["z_score"].abs() > 3]) |
| 95 | ``` |
| 96 | |
| 97 | ### Filtering and Selection |
| 98 | ```python |
| 99 | # Filter rows |
| 100 | filtered = df[df["status"] == "active"] |
| 101 | |
| 102 | # Select columns |
| 103 | subset = df[["name", "revenue", "date"]] |
| 104 | |
| 105 | # Sort |
| 106 | sorted_df = df.sort_values("revenue", ascending=False) |
| 107 | |
| 108 | # Convert to pandas for final output / iteration |
| 109 | result_pd = to_pd(sorted_df) |
| 110 | ``` |
| 111 | |
| 112 | ## Data Type Requirements |
| 113 | |
| 114 | cuDF requires explicit type specification for optimal performance: |
| 115 | - Use `float32` or `float64` for numeric data |
| 116 | - Use `int32` or `int64` for integer data |
| 117 | - String columns use cuDF's string dtype automatically |
| 118 | |
| 119 | ## Output Guidelines |
| 120 | |
| 121 | When reporting analysis results: |
| 122 | - Include dataset dimensions (rows x columns) |
| 123 | - Show key statistics in formatted tables |
| 124 | - Highlight notable patterns, trends, or anomalies |
| 125 | - Provide both summary statistics and specific examples |
| 126 | - Note any data quality issues (missing values, outliers) |