Skip to content

'sort_index"does not work with 'pd.set_option('mode.use_inf_as_na',True)' #29687

Closed
@asmcat666

Description

@asmcat666
In [12]: pd.set_option('mode.use_inf_as_na',False)

In [13]: df
Out[13]:
                            B
2018-09-25 14:47:31.500   0.0
2018-04-03 22:55:13.000   1.0
2018-09-04 09:10:07.500   2.0
2018-11-30 10:32:08.000   NaN
2018-03-27 14:21:12.500   4.0
2018-09-28 14:30:36.500   6.0
2018-07-16 21:56:48.000   7.0
2018-12-05 23:53:59.500   8.0
2018-09-04 09:46:58.500   9.0
2018-11-09 09:14:08.500  10.0

In [14]: df.sort_index()
Out[14]:
                            B
2018-03-27 14:21:12.500   4.0
2018-04-03 22:55:13.000   1.0
2018-07-16 21:56:48.000   7.0
2018-09-04 09:10:07.500   2.0
2018-09-04 09:46:58.500   9.0
2018-09-25 14:47:31.500   0.0
2018-09-28 14:30:36.500   6.0
2018-11-09 09:14:08.500  10.0
2018-11-30 10:32:08.000   NaN
2018-12-05 23:53:59.500   8.0

In [15]: pd.set_option('mode.use_inf_as_na',True)

In [16]: df.sort_index()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-16-02a473b4132d> in <module>
----> 1 df.sort_index()

g:\py372\lib\site-packages\pandas\core\frame.py in sort_index(self, axis, lev
 ascending, inplace, kind, na_position, sort_remaining, by)
   5088
   5089             indexer = nargsort(
-> 5090                 labels, kind=kind, ascending=ascending, na_position=n
osition
   5091             )
   5092

g:\py372\lib\site-packages\pandas\core\sorting.py in nargsort(items, kind, as
ding, na_position)
    244
    245     items = extract_array(items)
--> 246     mask = np.asarray(isna(items))
    247
    248     if is_extension_array_dtype(items):

g:\py372\lib\site-packages\pandas\core\dtypes\missing.py in isna(obj)
    120     Name: 1, dtype: bool
    121     """
--> 122     return _isna(obj)
    123
    124

g:\py372\lib\site-packages\pandas\core\dtypes\missing.py in _isna_old(obj)
    177         return _isna_ndarraylike_old(obj)
    178     elif isinstance(obj, ABCGeneric):
--> 179         return obj._constructor(obj._data.isna(func=_isna_old))
    180     elif isinstance(obj, list):
    181         return _isna_ndarraylike_old(np.asarray(obj, dtype=object))

AttributeError: 'DatetimeArray' object has no attribute '_constructor'

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