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

API: various .value_counts() result in different names / indices #49912

Merged
merged 36 commits into from
Feb 1, 2023
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0e50e19
sort out series / index case
Nov 25, 2022
214cc34
getting there...
Nov 25, 2022
c1fa208
only just fixed up another file!
Nov 25, 2022
d872960
more fixups
Nov 25, 2022
f7cf72a
getting there
Nov 25, 2022
6e281e1
wip, do this apply thing separately
Nov 25, 2022
0fc0bec
fixup
Nov 25, 2022
df6a108
more fixup
Nov 25, 2022
94187e4
tmp fixup per gh49909
Nov 25, 2022
f4734a2
:art:
Nov 25, 2022
eb8a070
fixup test
Nov 25, 2022
354dd95
fixup tests
Nov 25, 2022
ee9fb43
:label: typing
Nov 25, 2022
77b2bc7
:pencil: whatsnew
Nov 25, 2022
766a583
rewrite whatsnew
Nov 25, 2022
53608b3
add back missing line
Nov 25, 2022
19633a4
shorten
Nov 25, 2022
30a58e0
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
Dec 9, 2022
c2c0f38
pin name, simplify whatsnew example, reference issue, retitle
Dec 9, 2022
33f681e
Merge branch 'main' into just-change-value-counts
MarcoGorelli Dec 11, 2022
e24265a
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
Dec 18, 2022
2941826
avoid rename
Dec 18, 2022
2d40eac
Merge branch 'just-change-value-counts' of github.com:MarcoGorelli/pa…
Dec 18, 2022
ec48816
Merge branch 'main' into just-change-value-counts
MarcoGorelli Dec 27, 2022
016ddbb
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
Dec 30, 2022
1bf010e
Merge branch 'main' into just-change-value-counts
MarcoGorelli Jan 4, 2023
8b3e366
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
Jan 9, 2023
1ac51ab
fixup new test
Jan 9, 2023
6696d73
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
Jan 11, 2023
d80ad10
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
Jan 13, 2023
cacf010
adjust new path
Jan 13, 2023
8323c21
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
Jan 13, 2023
416ca2b
fixup
Jan 13, 2023
b4df34a
remove outdated comment
Jan 13, 2023
229132b
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
Jan 13, 2023
90d6afa
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into just-change-value-c…
…ounts
MarcoGorelli committed Dec 30, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 016ddbb5453e29d1572f0f722ca4a7b7cdd93f6b
16 changes: 14 additions & 2 deletions pandas/tests/base/test_value_counts.py
Original file line number Diff line number Diff line change
@@ -29,7 +29,13 @@ def test_value_counts(index_or_series_obj):

counter = collections.Counter(obj)
expected = Series(dict(counter.most_common()), dtype=np.int64, name="count")
expected.index = expected.index.astype(obj.dtype)

if obj.dtype != np.float16:
expected.index = expected.index.astype(obj.dtype)
else:
with pytest.raises(NotImplementedError, match="float16 indexes are not "):
expected.index.astype(obj.dtype)
return
if isinstance(expected.index, MultiIndex):
expected.index.names = obj.names
else:
@@ -78,7 +84,13 @@ def test_value_counts_null(null_obj, index_or_series_obj):
# np.nan would be duplicated, whereas None wouldn't
counter = collections.Counter(obj.dropna())
expected = Series(dict(counter.most_common()), dtype=np.int64, name="count")
expected.index = expected.index.astype(obj.dtype)

if obj.dtype != np.float16:
expected.index = expected.index.astype(obj.dtype)
else:
with pytest.raises(NotImplementedError, match="float16 indexes are not "):
expected.index.astype(obj.dtype)
return
expected.index.name = obj.name

result = obj.value_counts()
You are viewing a condensed version of this merge commit. You can view the full changes here.