Skip to content

BUG: index sorting with strings & timestamps #11244

Closed
@dniku

Description

@dniku

Pandas 0.16.2, Python 3.4.

test = pd.DataFrame({
    pd.Timestamp('2012-01-01 00:00:00'): ['a', 'b'],
    pd.Timestamp('2012-01-02 00:00:00'): ['c', 'd'],
    'name': ['e', 'e'],
    'aaaa': ['f', 'g']
    })
print(test)
print(test.groupby('name').first())

Fails with:

  File "/usr/lib64/python3.4/site-packages/pandas/core/groupby.py", line 106, in f
    self._set_selection_from_grouper()
  File "/usr/lib64/python3.4/site-packages/pandas/core/groupby.py", line 489, in _set_selection_from_grouper
    self._group_selection = ax.difference(Index(groupers)).tolist()
  File "/usr/lib64/python3.4/site-packages/pandas/core/index.py", line 1506, in difference
    theDiff = sorted(set(self) - set(other))
  File "pandas/tslib.pyx", line 836, in pandas.tslib._Timestamp.__richcmp__ (pandas/tslib.c:15612)
TypeError: Cannot compare type 'Timestamp' with type 'str'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions