diff --git a/docs/docs/Components/components-processing.md b/docs/docs/Components/components-processing.md index 71be45b03..022c4c828 100644 --- a/docs/docs/Components/components-processing.md +++ b/docs/docs/Components/components-processing.md @@ -90,17 +90,17 @@ John Smith This component can perform the following operations on Pandas [DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html). -| Operation | Description | Required Inputs | -|-----------|-------------|-----------------| -| Add Column | Adds a new column with a constant value | new_column_name, new_column_value | -| Drop Column | Removes a specified column | column_name | -| Filter | Filters rows based on column value | column_name, filter_value | -| Head | Returns first n rows | num_rows | -| Rename Column | Renames an existing column | column_name, new_column_name | -| Replace Value | Replaces values in a column | column_name, replace_value, replacement_value | -| Select Columns | Selects specific columns | columns_to_select | -| Sort | Sorts DataFrame by column | column_name, ascending | -| Tail | Returns last n rows | num_rows | +| Operation | Required Inputs | Info | +|-----------|----------------|-------------| +| Add Column | new_column_name, new_column_value | Adds a new column with a constant value. | +| Drop Column | column_name | Removes a specified column. | +| Filter | column_name, filter_value | Filters rows based on column value. | +| Head | num_rows | Returns first `n` rows. | +| Rename Column | column_name, new_column_name | Renames an existing column. | +| Replace Value | column_name, replace_value, replacement_value | Replaces values in a column. | +| Select Columns | columns_to_select | Selects specific columns. | +| Sort | column_name, ascending | Sorts DataFrame by column. | +| Tail | num_rows | Returns last `n` rows. |
Parameters @@ -129,6 +129,95 @@ This component can perform the following operations on Pandas [DataFrame](https:
+## Data operations + +This component performs operations on [Data](/concepts-objects#data-object) objects, including selecting keys, evaluating literals, combining data, filtering values, appending/updating data, removing keys, and renaming keys. + +1. To use this component in a flow, connect a component that outputs [Data](/concepts-objects#data-object) to the **Data Operations** component's input. +All operations in the component require at least one [Data](/concepts-objects#data-object) input. +2. In the **Operations** field, select the operation you want to perform. +For example, send this request to the **Webhook** component. +Replace `YOUR_FLOW_ID` with your flow ID. +```bash +curl -X POST "http://127.0.0.1:7860/api/v1/webhook/YOUR_FLOW_ID" \ +-H 'Content-Type: application/json' \ +-d '{ + "id": 1, + "name": "Leanne Graham", + "username": "Bret", + "email": "Sincere@april.biz", + "address": { + "street": "Kulas Light", + "suite": "Apt. 556", + "city": "Gwenborough", + "zipcode": "92998-3874", + "geo": { + "lat": "-37.3159", + "lng": "81.1496" + } + }, + "phone": "1-770-736-8031 x56442", + "website": "hildegard.org", + "company": { + "name": "Romaguera-Crona", + "catchPhrase": "Multi-layered client-server neural-net", + "bs": "harness real-time e-markets" + } +}' +``` + +3. In the **Data Operations** component, select the **Select Keys** operation to extract specific user information. +To add additional keys, click **Add More**. +![A webhook and data operations component](/img/component-data-operations-select-key.png) +4. Filter by `name`, `username`, and `email` to select the values from the request. +```json +{ + "name": "Leanne Graham", + "username": "Bret", + "email": "Sincere@april.biz" +} +``` + +### Operations + +The component supports the following operations. +All operations in the **Data operations** component require at least one [Data](/concepts-objects#data-object) input. + +| Operation | Required Inputs | Info | +|-----------|----------------|-------------| +| Select Keys | `select_keys_input` | Selects specific keys from the data. | +| Literal Eval | None | Evaluates string values as Python literals. | +| Combine | None | Combines multiple data objects into one. | +| Filter Values | `filter_key`, `filter_values`, `operator` | Filters data based on key-value pair. | +| Append or Update | `append_update_data` | Adds or updates key-value pairs. | +| Remove Keys | `remove_keys_input` | Removes specified keys from the data. | +| Rename Keys | `rename_keys_input` | Renames keys in the data. | + +
+Parameters + +**Inputs** + +| Name | Display Name | Info | +|------|--------------|------| +| data | Data | The [Data](/concepts-objects#data-object) object to operate on. | +| operations | Operations | The operation to perform on the data. | +| select_keys_input | Select Keys | A list of keys to select from the data. | +| filter_key | Filter Key | The key to filter by. | +| operator | Comparison Operator | The operator to apply for comparing values. | +| filter_values | Filter Values | A list of values to filter by. | +| append_update_data | Append or Update | The data to append or update the existing data with. | +| remove_keys_input | Remove Keys | A list of keys to remove from the data. | +| rename_keys_input | Rename Keys | A list of keys to rename in the data. | + +**Outputs** + +| Name | Display Name | Info | +|------|--------------|------| +| data_output | Data | The resulting Data object after the operation. | + +
+ ## Data to DataFrame This component converts one or multiple [Data](/concepts-objects#data-object) objects into a [DataFrame](/concepts-objects#dataframe-object). Each Data object corresponds to one row in the resulting DataFrame. Fields from the `.data` attribute become columns, and the `.text` field (if present) is placed in a 'text' column. diff --git a/docs/static/img/component-data-operations-select-key.png b/docs/static/img/component-data-operations-select-key.png new file mode 100644 index 000000000..d391a47ad Binary files /dev/null and b/docs/static/img/component-data-operations-select-key.png differ