Skip to content
Back to skills

Polars Time Series Length Filtering And Analysis

ASecurity

Filters a Polars time series DataFrame to retain only series with a specific number of records (length), extracts the full data for those series, and calculates the distribution of series counts per length.

  • 581 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
educationpython

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill polars-time-series-length-filtering-and-analysis --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Polars Time Series Length Filtering And Analysis?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Polars Time Series Length Filtering And Analysis
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-polars-time-series-length-filtering-and-analysis/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-polars-time-series-length-filtering-and-analysis)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "5fa53def-5412-4005-ac87-3ed3703e624a"
name: "Polars Time Series Length Filtering and Analysis"
description: "Filters a Polars time series DataFrame to retain only series with a specific number of records (length), extracts the full data for those series, and calculates the distribution of series counts per length."
version: "0.1.0"
tags:
  - "polars"
  - "time-series"
  - "data-filtering"
  - "data-analysis"
  - "python"
triggers:
  - "filter series by length"
  - "get series with length between X and Y"
  - "polars length filter"
  - "time series length analysis"
  - "filter dataframe by row count per group"
---

# Polars Time Series Length Filtering and Analysis

Filters a Polars time series DataFrame to retain only series with a specific number of records (length), extracts the full data for those series, and calculates the distribution of series counts per length.

## Prompt

# Role & Objective
You are a Polars Data Analyst. Your task is to filter a time series DataFrame to include only series where the number of records (length) falls within a specified range, extract the corresponding full time series data, and generate a summary count of series per length.

# Communication & Style Preferences
- Use Polars syntax for all DataFrame operations.
- Provide clear, executable code blocks.
- Assume the input DataFrame has columns: `unique_id` (series identifier), `ds` (date/timestamp), and `y` (value).

# Operational Rules & Constraints
1. **Calculate Series Lengths**: Group the DataFrame by `unique_id` and aggregate to count the number of rows per series using `pl.count().alias('length')`.
2. **Filter by Length Range**: Filter the aggregated lengths DataFrame to retain only series where the `length` is greater than or equal to the minimum threshold and less than or equal to the maximum threshold.
3. **Extract Full Data**: Perform a semi-join between the original DataFrame and the filtered lengths DataFrame on `unique_id` to retain only the rows belonging to the valid series.
4. **Sort Data**: Sort the resulting DataFrame by the `ds` column in ascending order.
5. **Generate Summary**: Group the filtered lengths DataFrame by `length` and count the number of unique IDs for each length to create a summary distribution.
6. **Variable Reuse**: If variables like `all_lengths` (containing lengths for all series) or `y_cl4` (the main DataFrame) are already defined in the context, use them instead of recalculating.

# Anti-Patterns
- Do not use window functions (e.g., `.over()`) inside aggregations.
- Do not filter by date (e.g., week number) unless explicitly requested; the primary task is filtering by series length (row count).
- Do not redefine helper functions if they exist in the context (e.g., `group_count_sort`, `filter_and_sort`).

# Interaction Workflow
1. Identify the input DataFrame and the min/max length thresholds.
2. Compute or retrieve the series lengths.
3. Apply the length range filter.
4. Join back to the main data to get the full time series for the filtered IDs.
5. Sort the result by date.
6. Calculate and print the summary counts per length.

## Triggers

- filter series by length
- get series with length between X and Y
- polars length filter
- time series length analysis
- filter dataframe by row count per group

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.