-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add dataframe operations component #5341
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/backend/base/langflow/components/processing/dataframe_operations.py:207
- The columns_to_select input should be split by a delimiter (e.g., comma) before stripping. Use columns = [col.strip() for col in self.columns_to_select.split(',')] to ensure correct column selection.
columns = [col.strip() for col in self.columns_to_select]
src/backend/base/langflow/components/processing/dataframe_operations.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….py` * **Import modules** - Import `pytest` and `pandas` for testing DataFrame operations * **Define test cases** - Define test cases for edge cases like empty DataFrames and invalid column names - Include tests for operations like "Head", "Tail", and "Replace Value" - Use `pytest.mark.parametrize` to test multiple operations with different inputs - Add detailed assertions to verify the correctness of DataFrame operations
…tions.py`. This deletion includes all unit tests related to various DataFrame operations such as adding, dropping, filtering, and renaming columns, as well as handling edge cases like empty DataFrames and invalid operations. The removal streamlines the test suite by eliminating outdated or redundant tests.
- Introduced a new test file for organizing test components. - Updated import paths for to reflect the new module structure. - Refactored test cases to use for better readability and maintainability. - Enhanced assertions in tests for various DataFrame operations, including handling of empty DataFrames and invalid operations. - Improved code formatting for consistency and clarity.
…intainability - Consolidated import statements for clarity. - Renamed variable `df` to `dataframe_copy` for better understanding. - Streamlined the `perform_operation` method by replacing `elif` with `if` statements for clearer logic flow. - Enhanced error message for unsupported operations to improve debugging. These changes aim to enhance the code structure and make future modifications easier.
…ons.py` - Modified expected values in parameterized tests for various DataFrame operations, including "Add Column", "Filter", "Sort", "Head", "Tail", and "Replace Value" to reflect new test scenarios. - Adjusted assertions to ensure they correctly validate the output of operations, particularly for lists of expected values. - Enhanced error handling in the test for invalid operations to provide clearer feedback on unsupported operation types. These changes improve the accuracy and robustness of the unit tests for DataFrame operations.
29ea045
to
8914516
Compare
…tances consistently
italojohnny
approved these changes
Dec 19, 2024
anovazzi1
pushed a commit
that referenced
this pull request
Dec 19, 2024
* add dataframe operations component * populate entire new column with value Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * [autofix.ci] apply automated fixes * Add unit tests for DataFrame operations in `test_dataframe_operations.py` * **Import modules** - Import `pytest` and `pandas` for testing DataFrame operations * **Define test cases** - Define test cases for edge cases like empty DataFrames and invalid column names - Include tests for operations like "Head", "Tail", and "Replace Value" - Use `pytest.mark.parametrize` to test multiple operations with different inputs - Add detailed assertions to verify the correctness of DataFrame operations * [autofix.ci] apply automated fixes * Remove test cases for DataFrame operations from `test_dataframe_operations.py`. This deletion includes all unit tests related to various DataFrame operations such as adding, dropping, filtering, and renaming columns, as well as handling edge cases like empty DataFrames and invalid operations. The removal streamlines the test suite by eliminating outdated or redundant tests. * Add unit tests for DataFrame operations in - Introduced a new test file for organizing test components. - Updated import paths for to reflect the new module structure. - Refactored test cases to use for better readability and maintainability. - Enhanced assertions in tests for various DataFrame operations, including handling of empty DataFrames and invalid operations. - Improved code formatting for consistency and clarity. * Refactor DataFrameOperationsComponent for improved readability and maintainability - Consolidated import statements for clarity. - Renamed variable `df` to `dataframe_copy` for better understanding. - Streamlined the `perform_operation` method by replacing `elif` with `if` statements for clearer logic flow. - Enhanced error message for unsupported operations to improve debugging. These changes aim to enhance the code structure and make future modifications easier. * Update unit tests for DataFrame operations in `test_dataframe_operations.py` - Modified expected values in parameterized tests for various DataFrame operations, including "Add Column", "Filter", "Sort", "Head", "Tail", and "Replace Value" to reflect new test scenarios. - Adjusted assertions to ensure they correctly validate the output of operations, particularly for lists of expected values. - Enhanced error handling in the test for invalid operations to provide clearer feedback on unsupported operation types. These changes improve the accuracy and robustness of the unit tests for DataFrame operations. * Refactor DataFrameOperationsComponent methods to return DataFrame instances consistently --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
lgtm
This PR has been approved by a maintainer
size:L
This PR changes 100-499 lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds a new component to handle various operations on DataFrames in the
langflow
library. The main changes include the addition of a new class,DataFrameOperationsComponent
, which supports multiple DataFrame operations and dynamically updates its configuration based on the selected operation.New Component Addition:
src/backend/base/langflow/components/processing/dataframe_operations.py
: Introduced theDataFrameOperationsComponent
class, which includes support for operations such as adding, dropping, filtering, renaming, sorting columns, and more. The component dynamically updates its input fields based on the selected operation.Key features of the new component: