Commit e9248b4
PERF: avoid unnecessary to_numpy conversion in value_counts for Arrow arrays
Previously, value_counts_internal would convert Arrow array counts to
NumPy just to call .sum() for normalization. This is unnecessary since
Series.sum() works correctly for all backends.
Changes:
- Remove unnecessary np.asarray(counts) conversion for Arrow arrays
- Remove unused counts variable assignments from bins and MultiIndex branches
- Use result.sum() instead of counts.sum() for normalization
This eliminates a performance bottleneck where Arrow-backed Series
would fall back to NumPy during value_counts operations.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent 780c27c commit e9248b4
1 file changed
+32
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
273 | 302 | | |
274 | 303 | | |
275 | 304 | | |
| |||
787 | 816 | | |
788 | 817 | | |
789 | 818 | | |
790 | | - | |
| 819 | + | |
791 | 820 | | |
792 | | - | |
793 | | - | |
794 | 821 | | |
795 | 822 | | |
796 | 823 | | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | 824 | | |
809 | | - | |
| 825 | + | |
810 | 826 | | |
811 | | - | |
812 | | - | |
813 | 827 | | |
814 | | - | |
815 | | - | |
816 | | - | |
| 828 | + | |
817 | 829 | | |
818 | 830 | | |
819 | 831 | | |
| |||
0 commit comments