-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: ensure Series.name is hashable, #12610 #12612
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -725,3 +725,14 @@ def f(): | |
self.assertEqual(s.dtype, 'timedelta64[ns]') | ||
s = Series([pd.NaT, np.nan, '1 Day']) | ||
self.assertEqual(s.dtype, 'timedelta64[ns]') | ||
|
||
def test_constructor_name_hashable(self): | ||
for n in [777, 777., 'name', datetime(2001, 11, 11), (1, ), u"\u05D0"]: | ||
for data in [[1, 2, 3], np.ones(3), {'a': 0, 'b': 1}]: | ||
s = Series(data, name=n) | ||
self.assertEqual(s.name, n) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to add similar tests for setting e.g.
type things There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here: https://github.com/pydata/pandas/blob/master/pandas/tests/series/test_alter_axes.py#L80 (add a new test), you can use some of the |
||
|
||
def test_constructor_name_unhashable(self): | ||
for n in [['name_list'], np.ones(2), {1: 2}]: | ||
for data in [['name_list'], np.ones(2), {1: 2}]: | ||
self.assertRaises(TypeError, Series, data, name=n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can do these in 2 tests. _hashable, and _unhashable. just put a loop in each one.