Skip to content

Conversation

@hombit
Copy link
Collaborator

@hombit hombit commented Feb 12, 2025

This PR fixes #50 with a temporal hack. We should open a pandas issue and work with pandas maintainers to contribute a proper solution to this problem.

Examples of formatting with this PR

>>> from nested_pandas.datasets import generate_data

>>> generate_data(3, 1)
          a         b                                        nested
0  0.263827  0.453190   [{t: 5.850555, flux: 84.944634, band: 'g'}]
1  0.561989  0.788521   [{t: 16.96538, flux: 81.045302, band: 'g'}]
2  0.752709  1.946682  [{t: 11.489896, flux: 52.094699, band: 'r'}]

>>> generate_data(3, 3)
          a         b                                             nested
0  0.037709  1.962112  [{t: 16.999902, flux: 65.742084, band: 'g'}; …...
1  0.278047  1.636276  [{t: 0.81424, flux: 11.695323, band: 'g'}; …] ...
2  0.460416  0.109109  [{t: 13.668602, flux: 15.618081, band: 'r'}; …...

>>> nf = generate_data(3, 3)
>>> nf.nested.nest['t'] = nf.nested.nest['t'].round(1)
>>> nf.nested.nest['flux'] = nf.nested.nest['flux'].round(1)
>>> nf
          a         b                                          nested
0  0.789335  0.542048   [{t: 5.8, flux: 92.2, band: 'g'}; …] (3 rows)
1  0.631588  0.953179  [{t: 13.6, flux: 59.3, band: 'r'}; …] (3 rows)
2  0.215239  0.840790   [{t: 7.6, flux: 25.3, band: 'g'}; …] (3 rows)

@hombit hombit requested a review from dougbrn February 12, 2025 22:19
@hombit hombit enabled auto-merge February 12, 2025 22:21
@codecov
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 76.59574% with 11 lines in your changes missing coverage. Please review.

Project coverage is 98.47%. Comparing base (bbe1866) to head (54dac6c).
Report is 173 commits behind head on main.

Files with missing lines Patch % Lines
src/nested_pandas/series/ext_array.py 76.59% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #195      +/-   ##
==========================================
- Coverage   99.44%   98.47%   -0.97%     
==========================================
  Files          13       13              
  Lines        1074     1118      +44     
==========================================
+ Hits         1068     1101      +33     
- Misses          6       17      +11     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

Before [bbe1866] <v0.3.4> After [80f4ab0] Ratio Benchmark (Parameter)
32.8±2ms 46.5±8ms ~1.42 benchmarks.ReassignHalfOfNestedSeries.time_run
10.1±0.06ms 10.6±0.3ms 1.06 benchmarks.NestedFrameAddNested.time_run
24.9±0.3ms 25.1±0.7ms 1.01 benchmarks.AssignSingleDfToNestedSeries.time_run
269M 269M 1.00 benchmarks.AssignSingleDfToNestedSeries.peakmem_run
91.6M 91.6M 1.00 benchmarks.NestedFrameAddNested.peakmem_run
96.1M 96M 1.00 benchmarks.NestedFrameQuery.peakmem_run
10.7±0.2ms 10.8±0.03ms 1.00 benchmarks.NestedFrameQuery.time_run
95.3M 95.2M 1.00 benchmarks.NestedFrameReduce.peakmem_run
289M 288M 1.00 benchmarks.ReassignHalfOfNestedSeries.peakmem_run
1.25±0.02ms 1.23±0.2ms 0.99 benchmarks.NestedFrameReduce.time_run

Click here to view all benchmarks.

Copy link
Collaborator

@dougbrn dougbrn left a comment

Choose a reason for hiding this comment

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

Thanks a ton for providing a detailed comment in the code for this. I don't have any real reservations about using this trick and think the output here is really useful.

@hombit hombit merged commit 6798700 into main Feb 13, 2025
9 of 11 checks passed
@hombit hombit deleted the ext_array_formatting_tricked branch February 13, 2025 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better string representation for nested elements

3 participants