Commit 780c27c
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 b43b95d commit 780c27c
2 files changed
+29
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
897 | 897 | | |
898 | 898 | | |
899 | 899 | | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | 900 | | |
904 | 901 | | |
905 | 902 | | |
906 | 903 | | |
907 | 904 | | |
908 | 905 | | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | 906 | | |
914 | 907 | | |
915 | 908 | | |
| |||
920 | 913 | | |
921 | 914 | | |
922 | 915 | | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | 916 | | |
928 | 917 | | |
929 | 918 | | |
| |||
951 | 940 | | |
952 | 941 | | |
953 | 942 | | |
954 | | - | |
| 943 | + | |
955 | 944 | | |
956 | 945 | | |
957 | 946 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
790 | 818 | | |
791 | 819 | | |
792 | 820 | | |
| |||
0 commit comments