Skip to content
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

ENH: fill_value argument for shift #15486

Closed
adbull opened this issue Feb 23, 2017 · 5 comments · Fixed by #24128
Closed

ENH: fill_value argument for shift #15486

adbull opened this issue Feb 23, 2017 · 5 comments · Fixed by #24128
Labels
Datetime Datetime data dtype Enhancement good first issue Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@adbull
Copy link
Contributor

adbull commented Feb 23, 2017

Feature Request

At the moment, the Series/DataFrame shift methods always fill with nans, which causes an upcast for boolean/integer types. In cases where there is an appropriate non-nan fill value, it would be useful to provide this value in shift, rather than having to correctly downcast the result. This would presumably also be more efficient than .shift().fillna() in those cases where no upcast is required.

Example Code

>>> pd.Series([True]).shift(fill_value=False)
0    False
dtype: bool
@jreback
Copy link
Contributor

jreback commented Feb 23, 2017

sure this is reasonable to add. Also wouldn't be very difficult, mostly just need to pass this thru to the lower level functions (where a fill_values is found).

care to do a PR?

@jreback jreback added Difficulty Novice Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Feb 23, 2017
@jreback jreback added this to the Next Major Release milestone Feb 23, 2017
@jreback jreback added Enhancement Datetime Datetime data dtype labels Feb 23, 2017
@linebp
Copy link
Contributor

linebp commented Apr 20, 2017

This is a copy of #15527 where work seems to be in progress?

@jreback
Copy link
Contributor

jreback commented Apr 20, 2017

@linebp this is the original reported issue, #15527 is a possible patch for this.

@samuelsinayoko
Copy link
Contributor

Looks like this still needs doing. I'm going to try and give this ago if nobody is working on it.

@samuelsinayoko
Copy link
Contributor

@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Dec 25, 2018
thoo added a commit to thoo/pandas that referenced this issue Dec 28, 2018
* upstream/master: (26 commits)
  DOC: Fixing doc upload (no such remote origin) (pandas-dev#24459)
  BLD: for C extension builds on mac, target macOS 10.9 where possible (pandas-dev#24274)
  POC: _eadata (pandas-dev#24394)
  DOC: Correct location (pandas-dev#24456)
  CI: Moving CircleCI build to Travis (pandas-dev#24449)
  BUG: Infer compression by default in read_fwf() (pandas-dev#22200)
  DOC: Fix minor typo in whatsnew (pandas-dev#24453)
  DOC: Add dateutil to intersphinx pandas-dev#24437 (pandas-dev#24443)
  DOC: Adding links to offset classes in timeseries.rst (pandas-dev#24448)
  DOC: Adding offsets to API ref (pandas-dev#24446)
  DOC: fix flake8 issue in groupby.rst (pandas-dev#24363)
  DOC: Fixing more doc warnings (pandas-dev#24438)
  API: Simplify repeat signature (pandas-dev#24447)
  BUG: to_datetime(Timestamp, utc=True) localizes to UTC (pandas-dev#24441)
  CLN: Cython Py2/3 Compatible Imports (pandas-dev#23940)
  DOC: Fixing more doc warnings (pandas-dev#24431)
  DOC: Removing old release.rst (pandas-dev#24427)
  BUG-24408 Series.dt does not maintain own copy of index (pandas-dev#24426)
  DOC: Fixing several doc warnings (pandas-dev#24430)
  ENH: fill_value argument for shift pandas-dev#15486 (pandas-dev#24128)
  ...
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Enhancement good first issue Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
5 participants