Skip to content

Commit

Permalink
Update whatsnew and add git PR to tests to denote changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nateyoder committed Dec 16, 2016
1 parent 504c2a2 commit ab168e7
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
100 changes: 100 additions & 0 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ Other enhancements
Backwards incompatible API changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Map on Index types now return other Index types
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- ``map`` on an ``Index`` now returns an ``Index``, not an array (:issue:`12766`)

.. ipython:: python
Expand All @@ -111,6 +115,102 @@ Backwards incompatible API changes

idx.map(lambda x: x * 2)

- ``map`` on an ``Index`` or ``MultiIndex`` returns the appropriate type depending on output dimensionality

.. ipython:: python

mi = MultiIndex.from_tuples([(1, 2), (2, 4)])
mi

Previous Behavior:

.. code-block:: ipython

In [5]: idx.map(lambda x: (x, x * 2))
Out[5]: array([(1, 2), (2, 4)], dtype=object)


In [6]: mi.map(lambda x: x[0])
Out[6]: array([1, 2])

New Behavior:

.. ipython:: python

idx.map(lambda x: (x, x * 2))

mi.map(lambda x: x[0])


- ``map`` on an ``CategoricalIndex`` now returns a ``CategoricalIndex``, not a Categorical

.. ipython:: python

ci = CategoricalIndex(list('ABABC'), categories=list('CBA'), ordered=True)
ci

Previous Behavior:

.. code-block:: ipython

In [7]: ci.map(lambda x: x.lower())
Out[7]:
[a, b, a, b, c]
Categories (3, object): [c < b < a]

New Behavior:

.. ipython:: python

ci.map(lambda x: x.lower())

- ``map`` on an ``DatetimeIndex`` or ``TimedeltaIndex`` now returns an ``Index`` instance

.. ipython:: python

dtidx = date_range(start='2016-01-01', end='2016-01-02')
dtidx

Previous Behavior:

.. code-block:: ipython

In [8]: dtidx.map(lambda x: x.day)
Out[8]: array([1, 2])

New Behavior:

.. ipython:: python

dtidx.map(lambda x: x.day)


- ``map`` on a Series withe datetime64 values may return int64 dtypes rather than int32

.. ipython:: python

s = Series(date_range('2011-01-02T00:00', '2011-01-02T02:00', freq='H').tz_localize('Asia/Tokyo'))
s

Previous Behavior:

.. code-block:: ipython

In [9]: s.map(lambda x: x.hour)
Out[9]:
0 0
1 1
2 2
dtype: int32


New Behavior:

.. ipython:: python

s.map(lambda x: x.hour)


.. _whatsnew_0200.api:

- ``CParserError`` has been renamed to ``ParserError`` in ``pd.read_csv`` and will be removed in the future (:issue:`12665`)
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/series/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def test_apply_datetimetz(self):
tm.assert_series_equal(result, exp)

# change dtype
# GH 14506 : Returned dtype changed from int32 to int64
result = s.apply(lambda x: x.hour)
exp = pd.Series(list(range(24)) + [0], name='XX', dtype=np.int64)
tm.assert_series_equal(result, exp)
Expand Down Expand Up @@ -317,6 +318,7 @@ def test_map_datetimetz(self):
tm.assert_series_equal(result, exp)

# change dtype
# GH 14506 : Returned dtype changed from int32 to int64
result = s.map(lambda x: x.hour)
exp = pd.Series(list(range(24)) + [0], name='XX', dtype=np.int64)
tm.assert_series_equal(result, exp)
Expand Down

0 comments on commit ab168e7

Please sign in to comment.