Skip to content

BUG: raise on frozenset construction by Series #4482

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 1 commit into from
Aug 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ pandas 0.13
(:issue:`4016`)
- Fixed Panel assignment with a transposed frame (:issue:`3830`)
- Raise on set indexing with a Panel and a Panel as a value which needs alignment (:issue:`3777`)
- frozenset objects now raise in the ``Series`` constructor (:issue:`4482`,
:issue:`4480`)

pandas 0.12
===========
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,9 @@ def __new__(cls, data=None, index=None, dtype=None, name=None,
data = [data.get(i, nan) for i in index]
elif isinstance(data, types.GeneratorType):
data = list(data)
elif isinstance(data, set):
raise TypeError('Set value is unordered')
elif isinstance(data, (set, frozenset)):
raise TypeError("{0!r} type is unordered"
"".format(data.__class__.__name__))

if dtype is not None:
dtype = np.dtype(dtype)
Expand Down
11 changes: 8 additions & 3 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2418,9 +2418,14 @@ def test_string_select(self):
expected = df[df.x == 'none']
assert_frame_equal(result,expected)

result = store.select('df',Term('x!=none'))
expected = df[df.x != 'none']
assert_frame_equal(result,expected)
try:
result = store.select('df',Term('x!=none'))
expected = df[df.x != 'none']
assert_frame_equal(result,expected)
except Exception as detail:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpcloud I guess will just leave this in here...and see what happens

print("[{0}]".format(detail))
print(store)
print(expected)

df2 = df.copy()
df2.loc[df2.x=='','x'] = np.nan
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ def test_constructor_tuple_of_tuples(self):

def test_constructor_set(self):
values = set([1, 2, 3, 4, 5])

self.assertRaises(TypeError, Series, values)
values = frozenset(values)
self.assertRaises(TypeError, Series, values)

def test_fromDict(self):
Expand Down