BUG: DataFrame.shift
shows different behavior for axis=1
when freq
is specified
#47039
Closed
3 tasks done
Labels
Bug
Datetime
Datetime data dtype
Index
Related to the Index class or subclasses
Regression
Functionality that used to work in a prior pandas version
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
As is defined in doc, when
freq
is specified, only values in axes are changed, while data are kept. Whenaxis=0
, things work well. However, whenaxis=1
, data are shifted as iffreq
is not specified. The strange thing is that whenfill_value
is supplied with a value,freq
argument worked. This behavior is not documented in https://pandas.pydata.org/docs/dev/reference/api/pandas.DataFrame.shift.html.Expected Behavior
shift
shows the same behavior for bothaxis
values wheneverfill_value
is supplied.As the change might break existing behaviors, it is better to correct this behavior since 1.5.0.
Installed Versions
INSTALLED VERSIONS
commit : 4bfe3d0
python : 3.9.12.final.0
python-bits : 64
OS : Darwin
OS-release : 21.4.0
Version : Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : zh_CN.UTF-8
pandas : 1.4.2
numpy : 1.21.2
pytz : 2021.3
dateutil : 2.8.2
pip : 21.2.4
setuptools : 61.2.0
Cython : 0.29.24
pytest : 6.2.4
hypothesis : 6.46.5
sphinx : 4.4.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.1.1
pandas_datareader: None
bs4 : 4.10.0
bottleneck : 1.3.4
brotli :
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : 2.0.1
matplotlib : 3.5.0
numba : None
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 8.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
snappy : None
sqlalchemy : 1.4.27
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: