From c4ec8fa6493aedad7019c380a643ae2b1be07642 Mon Sep 17 00:00:00 2001 From: pmg4s7lpo <3118629464@qq.com> Date: Wed, 7 Jan 2026 23:53:17 +0800 Subject: [PATCH] Delete 'toolorchestratoolsdata_processor.py' --- toolorchestratoolsdata_processor.py | 87 ----------------------------- 1 file changed, 87 deletions(-) delete mode 100644 toolorchestratoolsdata_processor.py diff --git a/toolorchestratoolsdata_processor.py b/toolorchestratoolsdata_processor.py deleted file mode 100644 index b54c278..0000000 --- a/toolorchestratoolsdata_processor.py +++ /dev/null @@ -1,87 +0,0 @@ -""" -数据处理工具示例 -符合ToolInterface接口规范 -""" -from typing import Dict, Any -import pandas as pd -import numpy as np -from ..core.orchestrator import ToolInterface, LogMixin - -class DataProcessorTool(ToolInterface, LogMixin): - """数据处理工具""" - - def __init__(self): - self._name = "data_processor" - self._version = "1.0.0" - - @property - def name(self) -> str: - return self._name - - @property - def version(self) -> str: - return self._version - - def execute(self, params: Dict[str, Any]) -> Dict[str, Any]: - """执行数据处理""" - try: - self.logger.info(f"开始数据处理,参数: {params}") - - # 输入验证 - data = params.get("data", []) - operation = params.get("operation", "clean") - - if not data: - raise ValueError("输入数据为空") - - # 转换为DataFrame - df = pd.DataFrame(data) - - # 执行不同操作 - if operation == "clean": - result = self._clean_data(df) - elif operation == "analyze": - result = self._analyze_data(df) - elif operation == "transform": - result = self._transform_data(df) - else: - raise ValueError(f"不支持的操作: {operation}") - - self.logger.info("数据处理完成") - return { - "status": "success", - "operation": operation, - "result": result, - "rows_processed": len(df) - } - - except Exception as e: - self.logger.error(f"数据处理失败: {str(e)}") - raise - - def _clean_data(self, df: pd.DataFrame) -> Dict: - """数据清洗""" - # 移除空值 - df_clean = df.dropna() - # 重置索引 - df_clean = df_clean.reset_index(drop=True) - - return { - "cleaned_data": df_clean.to_dict(orient="records"), - "removed_rows": len(df) - len(df_clean) - } - - def _analyze_data(self, df: pd.DataFrame) -> Dict: - """数据分析""" - numeric_cols = df.select_dtypes(include=[np.number]).columns - - analysis = {} - for col in numeric_cols: - analysis[col] = { - "mean": float(df[col].mean()), - "std": float(df[col].std()), - "min": float(df[col].min()), - "max": float(df[col].max()) - } - - return {"analysis": analysis} \ No newline at end of file