Skip to content

BUG: Series.pct_change raises error for empty series #57056

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
2 of 3 tasks
galipremsagar opened this issue Jan 24, 2024 · 0 comments · Fixed by #57058
Closed
2 of 3 tasks

BUG: Series.pct_change raises error for empty series #57056

galipremsagar opened this issue Jan 24, 2024 · 0 comments · Fixed by #57058
Labels
Bug Transformations e.g. cumsum, diff, rank
Milestone

Comments

@galipremsagar
Copy link

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

In [3]: s = pd.Series([])
In [4]: s
Out[4]: Series([], dtype: object)
In [5]: s = pd.Series([], dtype='float64')
In [6]: s.pct_change(periods=0)
.
.
ValueError: attempt to get argmax of an empty sequence
In [7]: s.pct_change(periods=0, fill_method=None)
Out[7]: Series([], dtype: float64)

Issue Description

Performing a pct_change on empty series raises error when fill_method=No_default, but works when fill_method=None

Expected Behavior

Return empty result.

Installed Versions

INSTALLED VERSIONS

commit : fd3f571
python : 3.10.2.final.0
python-bits : 64
OS : Darwin
OS-release : 23.2.0
Version : Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8
pandas : 2.2.0
numpy : 1.23.2
pytz : 2022.2.1
dateutil : 2.8.2
setuptools : 60.2.0
pip : 21.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.5.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : 2.8.4
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 11.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@galipremsagar galipremsagar added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 24, 2024
@rhshadrach rhshadrach added Transformations e.g. cumsum, diff, rank and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 24, 2024
@rhshadrach rhshadrach added this to the 2.2.1 milestone Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Transformations e.g. cumsum, diff, rank
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants