Skip to content

Sorting on Timestamp broken version 0.11 #3461

Closed
@rla3rd

Description

@rla3rd

Issue: frame.sort_index uses argsort for a single sort column, but _lexsort_indexer for multi-columns
need to do a transform on datetimens[64] before passing to ``lexsortindexer

In [54]: a.columns
Out[54]: Index([ticker, disclosuredate, txnid], dtype=object)

In [55]: a.values
Out[55]:
array([[A, 2010-03-09 00:00:00, 11110508],
[A, 2010-03-12 00:00:00, 11121853],
[A, 2011-02-15 00:00:00, 12488915],
[A, 2011-03-08 00:00:00, 12563380],
[A, 2011-04-22 00:00:00, 12653015],
[A, 2013-01-28 00:00:00, 15244694]], dtype=object)

In [56]: a.sort(columns=['disclosuredate']).values
Out[56]:
array([[A, 2010-03-09 00:00:00, 11110508],
[A, 2010-03-12 00:00:00, 11121853],
[A, 2011-04-22 00:00:00, 12653015],
[A, 2013-01-28 00:00:00, 15244694],
[A, 2011-03-08 00:00:00, 12563380],
[A, 2011-02-15 00:00:00, 12488915]], dtype=object)

In [57]: pd.version
Out[57]: '0.11.0'

In [58]: import time

In [59]: a['epoch'] = a['disclosuredate'].map(lambda x: time.mktime(x.timetuple()))

In [60]: a.sort(['epoch']).values
Out[60]:
array([[A, 2010-03-09 00:00:00, 11110508, 1268110800.0],
[A, 2010-03-12 00:00:00, 11121853, 1268370000.0],
[A, 2011-02-15 00:00:00, 12488915, 1297746000.0],
[A, 2011-03-08 00:00:00, 12563380, 1299560400.0],
[A, 2011-04-22 00:00:00, 12653015, 1303444800.0],
[A, 2013-01-28 00:00:00, 15244694, 1359349200.0]], dtype=object)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions