Skip to content

Commit

Permalink
Just apply to objects
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Mar 12, 2018
1 parent a609f48 commit a35f93c
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,10 @@ def fillna(self, value=None, method=None, limit=None):

if mask.any():
if method is not None:
# ffill / bfill
# The basic idea is to create an array of integer positions.
# Internally, we use iNaT and the datetime filling routines
# to avoid floating-point NaN. Once filled, we take on `self`
# to get the actual values.
func = pad_1d if method == 'pad' else backfill_1d
idx = np.arange(len(self), dtype='int64')
idx[mask] = iNaT
idx = _ensure_platform_int(func(idx, mask=mask,
limit=limit,
dtype='datetime64[ns]'))
idx[idx == iNaT] = -1 # missing value marker for take.
new_values = self.take(idx)
new_values = func(self.astype(object), limit=limit,
mask=mask)
new_values = self._constructor_from_sequence(new_values)
else:
# fill with value
new_values = self.copy()
Expand Down

0 comments on commit a35f93c

Please sign in to comment.