Skip to content

ENH: fill_value argument for shift #15527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
flake8 fixes.
  • Loading branch information
ResidentMario committed Feb 27, 2017
commit 8ef9305609bcc4794cdecb16f9769dca64750535
5 changes: 2 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5033,14 +5033,13 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,

@Appender(_shared_docs['shift'] % _shared_doc_kwargs)
def shift(self, periods=1, freq=None, axis=0, fill_value=np.nan):
import pdb; pdb.set_trace()

if periods == 0:
return self

block_axis = self._get_block_manager_axis(axis)
if freq is None:
new_data = self._data.shift(periods=periods, axis=block_axis, fill_value=fill_value)
new_data = self._data.shift(periods=periods, axis=block_axis,
fill_value=fill_value)
else:
return self.tshift(periods, freq)

Expand Down
3 changes: 2 additions & 1 deletion pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,8 @@ def shift(self, periods, axis=0, fill_value=np.nan, mgr=None):

# convert integer to float if necessary. need to do a lot more than
# that, handle boolean etc also
new_values, fill_value = _maybe_upcast(self.values, fill_value=fill_value)
new_values, fill_value = _maybe_upcast(self.values,
fill_value=fill_value)

# make sure array sent to np.roll is c_contiguous
f_ordered = new_values.flags.f_contiguous
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2383,8 +2383,8 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,

@Appender(generic._shared_docs['shift'] % _shared_doc_kwargs)
def shift(self, periods=1, freq=None, axis=0, fill_value=np.nan):
import pdb; pdb.set_trace()
return super(Series, self).shift(periods=periods, freq=freq, axis=axis, fill_value=fill_value)
return super(Series, self).shift(periods=periods, freq=freq, axis=axis,
fill_value=fill_value)

def reindex_axis(self, labels, axis=0, **kwargs):
""" for compatibility with higher dims """
Expand Down