Fix pandas SettingWithCopyWarning in nested column access #384
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.
Description
This PR addresses deprecation warnings that appear when running the test suite, specifically fixing a
SettingWithCopyWarning
that could occur when accessing nested columns via list notation.Changes
SettingWithCopyWarning Fix
Modified the
_getitem_list
method insrc/nested_pandas/nestedframe/core.py
to ensure operations are performed on a copy rather than a potential view:When accessing multiple columns including nested ones (e.g.,
nf[['a', 'b', 'nested.c']]
), the code subsequently sets nested columns on the result object. Without the explicit.copy()
, this could triggerSettingWithCopyWarning
in certain pandas versions when the initial selection returns a view rather than a copy.NumPy 2.0 Compatibility
Verified that the
__array__
method inNestedExtensionArray
already has the correct signature for NumPy 2.0 compatibility:No changes were needed as the implementation already properly handles the
copy
parameter as specified in the NumPy 2.0 migration guide.Testing
test_get_nested_columns
test___array__
Related Issues
Fixes deprecation warnings reported in the issue where pandas and numpy deprecation warnings appeared during test execution.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
epyc.astro.washington.edu
/usr/bin/python3 /home/REDACTED/.local/bin/pytest tests/ -W default::DeprecationWarning -W default::FutureWarning
(dns block)/usr/bin/python3 /home/REDACTED/.local/bin/pytest tests/nested_pandas/ -x -v
(dns block)nasa-irsa-euclid-q1.s3.us-east-1.amazonaws.com
/usr/bin/python3 /home/REDACTED/.local/bin/pytest tests/ -W default::DeprecationWarning -W default::FutureWarning
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.