add_computed_column
Add calculated columns to Excel worksheets using pandas formulas, cumulative sums, or rolling aggregations.
Instructions
Add a computed column either via pandas-eval formula or as a cumsum/rolling operation.
Args: file_path: Workbook path. sheet_name: Worksheet name. new_column_name: Column name to add. expression: Expression string for pandas.eval when column_type=='formula'. has_header: Whether the sheet has a header row. column_type: One of 'formula', 'cumsum', 'rolling'. source_col: Required for 'cumsum' and 'rolling'. window: Integer window for rolling operations. rolling_func: Aggregation for rolling (default 'mean').
Returns: str: Message indicating success and destination column.
Notes: - Accepts user-provided expressions — underlying code performs AST checks; docstring should link to safety doc.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| window | No | ||
| file_path | Yes | ||
| expression | Yes | ||
| has_header | No | ||
| sheet_name | Yes | ||
| source_col | No | ||
| column_type | No | formula | |
| rolling_func | No | mean | |
| new_column_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |