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

CLN: tshift & shift could be consolidated #11631

Closed
max-sixty opened this issue Nov 17, 2015 · 2 comments · Fixed by #34545
Closed

CLN: tshift & shift could be consolidated #11631

max-sixty opened this issue Nov 17, 2015 · 2 comments · Fixed by #34545
Labels
API Design Clean Datetime Datetime data dtype Deprecate Functionality to remove in pandas good first issue
Milestone

Comments

@max-sixty
Copy link
Contributor

Particularly now that shift only works on datetime-like indexes (#11211)

They look almost the same, although not exactly:

In [11]: df=pd.DataFrame(pd.np.random.rand(5,2), index=pd.date_range(periods=5, start='2000'))

In [12]: df
Out[12]: 
                   0         1
2000-01-01  0.640148  0.781291
2000-01-02  0.261649  0.652372
2000-01-03  0.642422  0.734348
2000-01-04  0.582657  0.601868
2000-01-05  0.848645  0.078437

In [13]: df.shift()
Out[13]: 
                   0         1
2000-01-01       NaN       NaN
2000-01-02  0.640148  0.781291
2000-01-03  0.261649  0.652372
2000-01-04  0.642422  0.734348
2000-01-05  0.582657  0.601868

In [14]: df.tshift()
Out[14]: 
                   0         1
2000-01-02  0.640148  0.781291
2000-01-03  0.261649  0.652372
2000-01-04  0.642422  0.734348
2000-01-05  0.582657  0.601868
2000-01-06  0.848645  0.078437

In [15]: df.shift(freq='D')
Out[15]: 
                   0         1
2000-01-02  0.640148  0.781291
2000-01-03  0.261649  0.652372
2000-01-04  0.642422  0.734348
2000-01-05  0.582657  0.601868
2000-01-06  0.848645  0.078437

In [16]: df.tshift(freq='D')
Out[16]: 
                   0         1
2000-01-02  0.640148  0.781291
2000-01-03  0.261649  0.652372
2000-01-04  0.642422  0.734348
2000-01-05  0.582657  0.601868
2000-01-06  0.848645  0.078437
@jreback
Copy link
Contributor

jreback commented Nov 18, 2015

yes, shift is implemented in terms of tshift (which is simply missing the axis arg).

So would take a PR to deprecate .tshift, move impl to .shift and change tests/such.

@jreback jreback added Datetime Datetime data dtype Difficulty Novice API Design Deprecate Functionality to remove in pandas Clean labels Nov 18, 2015
@jreback jreback added this to the Next Major Release milestone Nov 18, 2015
@max-sixty max-sixty changed the title CLN: Could tshift & shift be consolidated? CLN: tshift & shift could be consolidated Nov 22, 2015
@IamGianluca
Copy link

I'm having a look at this issue. I'll send a PR hopefully by end of next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Clean Datetime Datetime data dtype Deprecate Functionality to remove in pandas good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants