Agent SkillsOpenDCAI/DataFlow-WebUI › general-filter

general-filter

GitHub

GeneralFilter算子用于基于Lambda表达式对DataFrame进行行级过滤。通过组合多个布尔规则(AND逻辑)移除不满足条件的行,不涉及LLM调用或新增列,适用于数据流管道中的基础数据清洗场景。

skills/canonical/core_text/filter/general-filter/SKILL.md OpenDCAI/DataFlow-WebUI

Trigger Scenarios

需要对DataFrame按条件过滤行 使用Lambda表达式构建多条件筛选逻辑 数据预处理中去除不符合标准的记录

Install

npx skills add OpenDCAI/DataFlow-WebUI --skill general-filter -g -y
More Options

Non-standard path

npx skills add https://github.com/OpenDCAI/DataFlow-WebUI/tree/main/skills/canonical/core_text/filter/general-filter -g -y

Use without installing

npx skills use OpenDCAI/DataFlow-WebUI@general-filter

指定 Agent (Claude Code)

npx skills add OpenDCAI/DataFlow-WebUI --skill general-filter -a claude-code -g -y

安装 repo 全部 skill

npx skills add OpenDCAI/DataFlow-WebUI --all -g -y

预览 repo 内 skill

npx skills add OpenDCAI/DataFlow-WebUI --list

SKILL.md

Frontmatter
{
    "name": "general-filter",
    "description": "Reference documentation for the GeneralFilter operator. Covers the constructor, rule-based filtering logic, and pipeline usage notes.\nUse when: filtering rows based on column value conditions that can be expressed as lambda functions without LLM calls."
}

GeneralFilter Operator Reference

GeneralFilter filters DataFrame rows using a custom rule list, combining all rules with AND. It does not add new columns — it only removes rows that do not satisfy all conditions.

1. Import

from dataflow.operators.core_text import GeneralFilter

2. Constructor

GeneralFilter(
    filter_rules=[
        lambda df: df["score"] >= 4,
        lambda df: df["text"].str.len() > 10,
    ]
)
Parameter Required Default Description
filter_rules Yes None List of rules; each rule is a callable with signature (df: DataFrame) -> Series[bool]

Each rule returns a boolean Series the same length as the DataFrame; True means keep the row. Multiple rules are combined with AND.

3. run() Signature

op.run(
    storage=self.storage.step(),
)
# returns: "" (empty string)
Parameter Required Default Description
storage Yes None DataFlowStorage step object. The operator reads a DataFrame from here and writes the filtered DataFrame back.

Note: run() has no input_key / output_key parameters. Column names referenced in rules are written directly in the lambda.

Return Value

The method returns "" (empty string).

4. Actual Runtime Logic

The source code behavior is:

  1. Read the DataFrame from storage.read("dataframe").
  2. Initialize a boolean mask as pd.Series(True, index=df.index).
  3. For each rule in filter_rules:
    • Validate the rule is callable.
    • Call cond = rule_fn(df).
    • Validate cond is a boolean Series.
    • Update mask: mask &= cond.
  4. Filter the DataFrame: filtered_df = df[mask].
  5. Write the filtered DataFrame back via storage.write(filtered_df).
  6. Return "".

Key Behavior Notes

  1. Each rule must return a boolean pd.Series; otherwise raises ValueError.
  2. Columns referenced in rules must already exist in the current step's DataFrame.
  3. Only removes rows; adds no new columns.
  4. Multiple rules are combined with AND — only rows satisfying all conditions are kept.

5. Pipeline Usage Pattern

from dataflow.operators.core_text import GeneralFilter
from dataflow.utils.storage import FileStorage

class MyPipeline:
    def __init__(self):
        self.storage = FileStorage(
            first_entry_file_name="./data/input.jsonl",
            cache_path="./cache",
            file_name_prefix="step",
            cache_type="jsonl"
        )

        self.filter = GeneralFilter(
            filter_rules=[
                lambda df: df["score"] >= 4,
                lambda df: df["text"].str.len() > 10,
            ]
        )

    def forward(self):
        self.filter.run(storage=self.storage.step())

if __name__ == "__main__":
    pipeline = MyPipeline()
    pipeline.forward()

Note: forward() has no return value, following the standard pipeline pattern.

Version History

  • 2e95d40 Current 2026-08-27 09:03

Same Skill Collection

skills/canonical/core_text/eval/bench-dataset-evaluator-question/SKILL.md
skills/canonical/core_text/eval/bench-dataset-evaluator/SKILL.md
skills/canonical/core_text/eval/prompted-evaluator/SKILL.md
skills/canonical/core_text/eval/text2qa-sample-evaluator/SKILL.md
skills/canonical/core_text/eval/unified-bench-dataset-evaluator/SKILL.md
skills/canonical/core_text/filter/kcentergreedy-filter/SKILL.md
skills/canonical/core_text/filter/prompted-filter/SKILL.md
skills/canonical/core_text/generate/bench-answer-generator/SKILL.md
skills/canonical/core_text/generate/chunked-prompted-generator/SKILL.md
skills/canonical/core_text/generate/embedding-generator/SKILL.md
skills/canonical/core_text/generate/format-str-prompted-generator/SKILL.md
skills/canonical/core_text/generate/prompted-generator/SKILL.md
skills/canonical/core_text/generate/retrieval-generator/SKILL.md
skills/canonical/core_text/generate/text2multihopqa-generator/SKILL.md
skills/canonical/core_text/refine/pandas-operator/SKILL.md
skills/canonical/core_text/refine/prompted-refiner/SKILL.md
skills/canonical/core_text/SKILL.md
skills/canonical/dataflow-dev/SKILL.md
skills/canonical/dataflow-operator-builder/SKILL.md
skills/canonical/generating-dataflow-pipeline/SKILL.md
skills/canonical/prompt-template-builder/SKILL.md
skills/canonical/core_text/generate/random-domain-knowledge-row-generator/SKILL.md

Metadata

Files
0
Version
2e95d40
Hash
29a53a27
Indexed
2026-08-27 09:03

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-27 13:52
浙ICP备14020137号-1 $Гость$