Skip to content

API/ERR: allow iterators in df.set_index & improve errors #24984

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

Merged
merged 36 commits into from
Feb 24, 2019
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3e01681
API: re-enable custom label types in set_index
h-vetinari Jan 28, 2019
1b71e68
Fix doc pattern?
h-vetinari Jan 28, 2019
caeb125
Review (TomAugspurger)
h-vetinari Jan 29, 2019
8bd5340
Review (jreback)
h-vetinari Jan 29, 2019
3c8b69a
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Jan 29, 2019
cdfd86a
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Jan 30, 2019
d76ecfb
Review (jreback & jorisvandenbossche)
h-vetinari Jan 30, 2019
d2ffb81
Revert last two commits
h-vetinari Jan 30, 2019
5863678
Review (jorisvandenbossche)
h-vetinari Jan 31, 2019
0a7d783
Fix hashable listlikes (review jorisvandenbossche)
h-vetinari Jan 31, 2019
087d4f1
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Jan 31, 2019
794f61d
Stabilize repr of frozenset
h-vetinari Feb 1, 2019
0761633
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 1, 2019
c58e8b6
Review (WillAyd)
h-vetinari Feb 1, 2019
29fa8c0
Unambiguous KeyError message
h-vetinari Feb 1, 2019
b5c8fa8
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 3, 2019
5590433
Remove redundant whatsnew
h-vetinari Feb 3, 2019
7767ff7
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 7, 2019
37c12d0
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 9, 2019
2c4eaea
Review (jorisvandenbossche)
h-vetinari Feb 9, 2019
6c78816
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 10, 2019
2ccd9a9
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 14, 2019
b03c43b
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 17, 2019
ea10359
Review (jreback)
h-vetinari Feb 17, 2019
ca17895
Retrigger after connectivity issues
h-vetinari Feb 17, 2019
a401eea
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 17, 2019
f4deacc
Review (jorisvandenbossche)
h-vetinari Feb 18, 2019
125b0ca
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 18, 2019
9bfcfde
move test for easier diff
h-vetinari Feb 18, 2019
6838613
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 19, 2019
ca2ac60
Review (jreback)
h-vetinari Feb 19, 2019
87bd0a6
Add 'conda list' for azure/posix after activate 'pandas-dev'
h-vetinari Feb 19, 2019
759b369
Revert "Add 'conda list' for azure/posix after activate 'pandas-dev'"
h-vetinari Feb 20, 2019
40f1aaa
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 20, 2019
ecc7d03
Reflect change in docstring
h-vetinari Feb 21, 2019
5f99b15
Merge remote-tracking branch 'upstream/master' into set_index_custom
h-vetinari Feb 24, 2019
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
Stabilize repr of frozenset
  • Loading branch information
h-vetinari committed Feb 1, 2019
commit 794f61d4d77d075b37e40144ed3adbda669ace64
18 changes: 12 additions & 6 deletions pandas/tests/frame/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,8 @@ def __init__(self, name, color):
def __str__(self):
return "<Thing %r>" % (self.name,)

def __repr__(self):
# necessary for pretty KeyError
return self.__str__()
# necessary for pretty KeyError
__repr__ = __str__

thing1 = Thing('One', 'red')
thing2 = Thing('Two', 'blue')
Expand Down Expand Up @@ -318,8 +317,15 @@ def test_set_index_custom_label_hashable_iterable(self):
# objects (e.g. a collection of Points) that can be both hashable and
# iterable; using frozenset as a stand-in for testing here

thing1 = frozenset(['One', 'red'])
thing2 = frozenset(['Two', 'blue'])
class Thing(frozenset):
# need to stabilize repr for KeyError (due to random order in sets)
def __repr__(self):
tmp = sorted(list(self))
# double curly brace prints one brace in format string
return "frozenset({{{}}})".format(', '.join(map(repr, tmp)))

thing1 = Thing(['One', 'red'])
thing2 = Thing(['Two', 'blue'])
df = DataFrame({thing1: [0, 1], thing2: [2, 3]})
expected = DataFrame({thing1: [0, 1]},
index=Index([2, 3], name=thing2))
Expand All @@ -333,7 +339,7 @@ def test_set_index_custom_label_hashable_iterable(self):
tm.assert_frame_equal(result, expected)

# missing key
thing3 = frozenset(['Three', 'pink'])
thing3 = Thing(['Three', 'pink'])
msg = r"frozenset\(\{'Three', 'pink'\}\)"
with pytest.raises(KeyError, match=msg):
# missing label directly
Expand Down