Skip to content
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

Allow nested field names to be escaped with backticks. #177

Merged
merged 8 commits into from
Nov 27, 2024

Conversation

gitosaurus
Copy link
Contributor

Change Description

Extends the support of the Pandas backtick convention in eval and query to support nested column and field names. Because the "." operator is used as a path separator in NestedFrame.__setitem__ and NestedFrame.__getitem__, this same convention is followed within those methods to allow users to work around cases when the column name unavoidably contains spaces or dots itself. This context is not a full evaluation context, but when NestedFrame is performing an evaluation, and prepares aliases, these are reused in order to avoid recomputing them.

While this also lays the foundation for supporting more than one level of nesting, this PR does not enable any more than one level of nesting, and continues to follow existing conventions in this case. It does allow users to work with column names having any number of dots or spaces in them by employing backticks.

Closes #176 .

  • My PR includes a link to the issue that I am addressing

Solution Description

Code Quality

  • I have read the Contribution Guide
  • My code follows the code style of this project
  • My code builds (or compiles) cleanly without any errors or warnings
  • My code contains relevant comments and necessary documentation

Project-Specific Pull Request Checklists

New Feature Checklist

  • I have added or updated the docstrings associated with my feature using the NumPy docstring format
  • I have updated the tutorial to highlight my new feature (if appropriate)
  • I have added unit/End-to-End (E2E) test cases to cover my new feature
  • My change includes a breaking change
    • My change includes backwards compatibility and deprecation warnings (if possible)

This allows dots, spaces, and more, while still permitting the dot
to function as a path separator.
It's the only class that uses it, so make it private.
Also allows it to make the complicated check for whether _aliases
is present.
This will cut down on the number of times that aliases are computed.
Copy link

codecov bot commented Nov 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.43%. Comparing base (a86a532) to head (e247940).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #177      +/-   ##
==========================================
+ Coverage   99.40%   99.43%   +0.02%     
==========================================
  Files          13       13              
  Lines        1016     1062      +46     
==========================================
+ Hits         1010     1056      +46     
  Misses          6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gitosaurus gitosaurus linked an issue Nov 23, 2024 that may be closed by this pull request
3 tasks
Copy link

github-actions bot commented Nov 23, 2024

Before [a86a532] <v0.3.2> After [311b1d8] Ratio Benchmark (Parameter)
29.0±0.6ms 30.0±7ms 1.03 benchmarks.ReassignHalfOfNestedSeries.time_run
14.5±0.1ms 14.6±0.09ms 1.01 benchmarks.NestedFrameQuery.time_run
266M 266M 1 benchmarks.AssignSingleDfToNestedSeries.peakmem_run
21.3±0.1ms 21.4±0.1ms 1 benchmarks.AssignSingleDfToNestedSeries.time_run
88.4M 88.4M 1 benchmarks.NestedFrameAddNested.peakmem_run
9.19±0.1ms 9.20±0.1ms 1 benchmarks.NestedFrameAddNested.time_run
93.2M 93.4M 1 benchmarks.NestedFrameQuery.peakmem_run
91.9M 91.9M 1 benchmarks.NestedFrameReduce.peakmem_run
1.59±0.01ms 1.58±0.01ms 1 benchmarks.NestedFrameReduce.time_run
285M 285M 1 benchmarks.ReassignHalfOfNestedSeries.peakmem_run

Click here to view all benchmarks.

Copy link
Collaborator

@hombit hombit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

src/nested_pandas/nestedframe/core.py Show resolved Hide resolved
src/nested_pandas/nestedframe/core.py Show resolved Hide resolved
src/nested_pandas/nestedframe/core.py Show resolved Hide resolved
src/nested_pandas/nestedframe/core.py Show resolved Hide resolved
@gitosaurus gitosaurus requested a review from hombit November 27, 2024 18:42
@gitosaurus gitosaurus enabled auto-merge (rebase) November 27, 2024 18:44
Copy link
Collaborator

@hombit hombit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you

@gitosaurus gitosaurus merged commit 3cb19bd into main Nov 27, 2024
10 checks passed
@gitosaurus gitosaurus deleted the 176-non-identifier-nested-field-names branch November 27, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants