Stop Series from attempting to sort index

31 views
Skip to first unread message

Brendan Barnwell

unread,
May 18, 2013, 5:02:04 PM5/18/13
to pyd...@googlegroups.com
It appears that it is not possible to create a Series from a dict whose keys are unorderable.  Series.__init__ unconditionally attempts to sort a dict that is passed as the data.

>>> pandas.Series({1j: 1, 2j: 2})
Traceback (most recent call last):
  File "<pyshell#33>", line 1, in <module>
    pandas.Series({1j: 1, 2j: 2})
  File "c:\users\brenbarn\documents\python\extensions\pandas\pandas\core\series.py", line 444, in __new__
    index = Index(sorted(data))
TypeError: no ordering relation is defined for complex numbers

Should I raise a ticket for this?  It's possible to work around it by passing in the dict values as the data and the keys as the indices, but this is somewhat cumbersome.  It would be nice to just have a flag to pass to Series to say "don't try to sort anything".

Wes McKinney

unread,
May 19, 2013, 5:49:42 PM5/19/13
to pyd...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups
> "PyData" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pydata+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Yes, could you create a github issue? Definitely a bug.

- Wes

Wouter Overmeire

unread,
May 21, 2013, 3:11:53 PM5/21/13
to pyd...@googlegroups.com



2013/5/19 Wes McKinney <wesm...@gmail.com>


adding reference to the created github issue for this  https://github.com/pydata/pandas/issues/3658
Reply all
Reply to author
Forward
0 new messages