Skip to content

Commit 7d9061a

Browse files
committed
tests for CI
1 parent 2566af6 commit 7d9061a

File tree

2 files changed

+54
-29
lines changed

2 files changed

+54
-29
lines changed

doc/source/whatsnew/v0.20.0.txt

+45-29
Original file line numberDiff line numberDiff line change
@@ -599,52 +599,68 @@ ndarray, you can always convert explicitly using ``np.asarray(idx.hour)``.
599599
pd.unique will now be consistent with extension types
600600
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
601601

602-
In prior versions, using ``Series.unique()`` and ``pd.unique(Series)`` on ``Categorical`` and tz-aware datatypes would yield different return types. These are now consistent to return the extension type. Note that the behavior of ``Index.unique()`` and ``pd.unique(Index)`` has not changed. (:issue:`15939`)
602+
In prior versions, using ``Series.unique()`` and ``pd.unique(Series)`` on ``Categorical`` and tz-aware datatypes would yield different return types. These are now consistent to return the extension type.
603603

604-
Previous behaviour:
604+
- Datetime tz-aware
605605

606-
Datetime tz-aware
606+
Previous behaviour:
607607

608-
.. code-block:: ipython
608+
.. code-block:: ipython
609609

610-
In [5]: Series(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
611-
pd.Timestamp('20160101', tz='US/Eastern')])).unique()
612-
Out[5]: array([Timestamp('2016-01-01 00:00:00-0500', tz='US/Eastern')], dtype=object)
610+
# Series
611+
In [5]: Series(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
612+
pd.Timestamp('20160101', tz='US/Eastern')])).unique()
613+
Out[5]: array([Timestamp('2016-01-01 00:00:00-0500', tz='US/Eastern')], dtype=object)
613614

614-
In [7]: pd.unique(Series(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
615-
pd.Timestamp('20160101', tz='US/Eastern')])))
616-
Out[7]: array(['2016-01-01T05:00:00.000000000'], dtype='datetime64[ns]')
615+
In [6]: pd.unique(Series(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
616+
pd.Timestamp('20160101', tz='US/Eastern')])))
617+
Out[6]: array(['2016-01-01T05:00:00.000000000'], dtype='datetime64[ns]')
617618

618-
Categoricals
619+
# Index
620+
In [7]: pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
621+
pd.Timestamp('20160101', tz='US/Eastern')]).unique()
622+
Out[7]: DatetimeIndex(['2016-01-01 00:00:00-05:00'], dtype='datetime64[ns, US/Eastern]', freq=None)
619623

620-
.. code-block:: ipython
624+
In [8]: pd.unique(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
625+
pd.Timestamp('20160101', tz='US/Eastern')]))
626+
Out[8]: array(['2016-01-01T05:00:00.000000000'], dtype='datetime64[ns]')
621627

628+
New Behavior:
622629

623-
In [1]: pd.Series(pd.Categorical(list('aabc'))).unique()
624-
Out[1]:
625-
[a, b, c]
626-
Categories (3, object): [a, b, c]
630+
.. ipython:: python
627631

628-
In [2]: pd.unique(pd.Series(pd.Categorical(list('aabc'))).unique())
629-
Out[2]: array(['a', 'b', 'c'], dtype=object)
632+
# Series
633+
Series(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
634+
pd.Timestamp('20160101', tz='US/Eastern')])).unique()
635+
pd.unique(Series(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
636+
pd.Timestamp('20160101', tz='US/Eastern')])))
630637

631-
New Behavior:
638+
# Index
639+
pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
640+
pd.Timestamp('20160101', tz='US/Eastern')])
641+
pd.unique(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
642+
pd.Timestamp('20160101', tz='US/Eastern')]))
632643

633-
Datetime tz-aware
644+
- Categoricals
634645

635-
.. ipython:: python
646+
Previous behaviour:
647+
648+
.. code-block:: ipython
636649

637-
Series(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
638-
pd.Timestamp('20160101', tz='US/Eastern')])).unique()
639-
pd.unique(Series(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
640-
pd.Timestamp('20160101', tz='US/Eastern')])))
650+
In [1]: pd.Series(pd.Categorical(list('aabc'))).unique()
651+
Out[1]:
652+
[a, b, c]
653+
Categories (3, object): [a, b, c]
641654

642-
Categoricals
655+
In [2]: pd.unique(pd.Series(pd.Categorical(list('aabc'))).unique())
656+
Out[2]: array(['a', 'b', 'c'], dtype=object)
643657

644-
.. ipython:: python
658+
New Behavior:
659+
660+
.. ipython:: python
645661

646-
pd.Series(pd.Categorical(list('aabc'))).unique()
647-
pd.unique(pd.Series(pd.Categorical(list('aabc'))).unique())
662+
pd.Series(pd.Categorical(list('aabc'))).unique()
663+
pd.unique(pd.Series(pd.Categorical(list('aabc'))).unique())
648664

649665
.. _whatsnew_0200.api_breaking.s3:
650666

pandas/tests/test_algos.py

+9
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,15 @@ def test_categorical(self):
399399
expected = Series(expected, name='foo')
400400
tm.assert_series_equal(result, expected)
401401

402+
# CI
403+
ci = pd.CategoricalIndex(pd.Categorical(list('aabc')))
404+
result = ci.unique()
405+
expected = pd.CategoricalIndex(pd.Categorical(list('abc')))
406+
tm.assert_index_equal(result, expected)
407+
408+
result = pd.unique(ci)
409+
tm.assert_index_equal(result, expected)
410+
402411
def test_datetime64tz_aware(self):
403412
# GH 15939
404413

0 commit comments

Comments
 (0)