Executing Custom Code
The Execute Custom Code feature allows users to create a dynamic column by writing and running Python code on dataset rows. This enables custom transformations, calculations, or data processing based on existing column values.
By defining a function, users can manipulate row-level data and store the results in a new column.
1. Select a Dataset
Before executing custom code, ensure you have selected a dataset from your workspace. If no dataset is available, follow the steps to Add Dataset on the Future AGI platform.
2. Accessing the Custom Code Execution Interface
To configure a custom column, navigate to your dataset and click the + Add Columns button in the top-right menu. Scroll down to the Dynamic Columns section and select Execute Custom Code to open the setup panel.
3. Configuring Custom Code Execution
- Name: Assign a name to the new column where the computed results will be stored.
- Python Code: Write a Python function to process row data. The function should be named
main
and accept keyword arguments (kwargs
) to access column values. - Concurrency: Define how many rows should be processed simultaneously for efficiency.
After writing the function, click Test to preview the computed values. If the output is correct, click Create New Column to apply the function to all rows in the dataset. The newly created column will update dynamically with computed values.
Best Practices for Custom Code Execution
- Use simple, efficient Python logic to avoid performance issues.
- Ensure column names are correctly referenced in the function.
- Test the function before applying it to catch errors early.
- Optimize concurrency settings for large datasets to balance speed and processing power.