A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/11631 below:

tshift & shift could be consolidated · Issue #11631 · pandas-dev/pandas · GitHub

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4