Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ Backwards incompatible API changes
- Incorrectly passing a :class:`DatetimeIndex` to :meth:`MultiIndex.from_tuples`, rather than a sequence of tuples, now raises a ``TypeError`` rather than a ``ValueError`` (:issue:`24024`)
- :func:`pd.offsets.generate_range` argument ``time_rule`` has been removed; use ``offset`` instead (:issue:`24157`)
- In 0.23.x, pandas would raise a ``ValueError`` on a merge of a numeric column (e.g. ``int`` dtyped column) and an ``object`` dtyped column (:issue:`9780`). We have re-enabled the ability to merge ``object`` and other dtypes; pandas will still raise on a merge between a numeric and an ``object`` dtyped column that is composed only of strings (:issue:`21681`)
- Passing an integer to :method:`Series.fillna` on a ``Series`` with ``timedelta64[ns]`` dtype will now treat that integer as a number of nanoseconds instead of a number of seconds (:issue:`24694`)

Percentage change on groupby
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2499,9 +2499,9 @@ def _can_hold_element(self, element):
def fillna(self, value, **kwargs):

# allow filling with integers to be
# interpreted as seconds
# interpreted as nanoseconds
if is_integer(value) and not isinstance(value, np.timedelta64):
value = Timedelta(value, unit='s')
value = self._box_func(value)
return super(TimeDeltaBlock, self).fillna(value, **kwargs)

def _try_coerce_args(self, values, other):
Expand Down
7 changes: 4 additions & 3 deletions pandas/tests/series/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pandas as pd
from pandas import (
Categorical, DataFrame, Index, IntervalIndex, MultiIndex, NaT, Series,
Timestamp, date_range, isna)
Timedelta, Timestamp, date_range, isna)
from pandas.core.series import remove_na
import pandas.util.testing as tm
from pandas.util.testing import assert_frame_equal, assert_series_equal
Expand Down Expand Up @@ -70,9 +70,10 @@ def test_timedelta_fillna(self):
timedelta(days=1, seconds=9 * 3600 + 60 + 1)])
assert_series_equal(result, expected)

# interprested as seconds
# interprested as nanoseconds
result = td.fillna(1)
expected = Series([timedelta(seconds=1), timedelta(0), timedelta(1),
expected = Series([Timedelta(nanoseconds=1),
timedelta(0), timedelta(1),
timedelta(days=1, seconds=9 * 3600 + 60 + 1)])
assert_series_equal(result, expected)

Expand Down