You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The 'generic' unit for NumPy timedelta is deprecated. #2914
Getting depreciation messages even in the latest version 1.5.1:
/.venv/lib/python3.14/site-packages/yfinance/scrapers/quote.py:254: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+1`).Please use a specific unit instead. shares = self._tkr.get_shares_full(start=pd.Timestamp.now('UTC').date()-pd.Timedelta(days=548))
/.venv/lib/python3.14/site-packages/yfinance/utils.py:667: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead. last_rows_same_interval = (dt2 - dt1) < _pd.Timedelta(interval)
Looked into this. The utils.py site was already reworked on dev in d8e2cfe (sub-day intervals now map to explicit units), and #2915 fixes the remaining quote.py site plus a TypeError regression d8e2cfe introduced for the "5d" interval.
One thing I could not do is reproduce the generic-unit warning itself — tried pandas 2.3.3/3.0.3 x numpy 2.4.6/2.5.1 on Python 3.11/3.12/3.14, all clean. Could you share your numpy version (python -c "import numpy; print(numpy.__version__)")? Wondering if it needs a numpy dev build to trigger.
Thanks for the versions — that was the missing piece, and it let me reproduce it. My earlier "can't reproduce" was wrong: the trigger is numpy ≥ 2.5.0, and I had been testing against 2.4.6.
Built your exact stack (Python 3.14, numpy 2.5.1, pandas 2.3.3) and pinned it down. The warning has nothing to do with yfinance — it comes from inside pandas, on anyTimedelta construction:
No yfinance imported. pd.Timedelta(days=1) does it too. The comparison and the subtraction in those two tracebacks are both clean — it is purely the Timedelta(...) call, so quote.py:254 and utils.py:667 are just the first two constructions a normal session happens to reach.
Version matrix, all on Python 3.14:
numpy
pandas
result
2.4.6
2.3.3
clean
2.5.0
2.3.3
warns
2.5.1
2.3.3
warns
2.5.1
3.0.0
clean
2.5.1
3.0.3
clean
So it is a pandas-2.x/numpy-2.5 incompatibility, exactly as your pandas bump suggested. Worth noting 2.3.3 is the final 2.x release, so that line will not be getting a fix — upgrading to pandas ≥ 3.0 is the only remedy.
One thing for the maintainers: setup.py currently asks for pandas>=1.3.0 and numpy>=1.16.5, so pandas 2.3.3 + numpy 2.5.1 is a fully legal resolution of yfinance's own constraints and this will keep being reported. Might be worth either documenting it or requiring pandas>=3.0 when numpy>=2.5.
Also flagging so this doesn't get closed by the wrong thing: #2915 is unrelated to this warning. It fixes a genuine TypeError regression on the "5d" interval plus some date-arithmetic patterns, and it will not silence this deprecation — nothing in yfinance can, since the warning is raised before yfinance's own code gets involved.
Small correction to what I said earlier. I claimed nothing in yfinance could silence this and only a pandas upgrade would — that's only half right.
The warning does come from inside pandas' Timedelta construction, so a Timedelta you build yourself will still warn until pandas 3.0. But yfinance controls how it constructs the Timedeltas on the two lines from your traceback, and it turns out the construction form matters on this stack (numpy 2.5.1 / pandas 2.3.3):
pd.Timedelta(days=548) and pd.Timedelta(minutes=90) — the keyword forms — still warn
pd.Timedelta(548, unit="D") — the (value, unit=...) form — is silent
The existing workaround for #2882 used the keyword form, so it never actually suppressed the warning — its regression test fails on numpy 2.5.1. #2915 switches those sites (including quote.py:254, the first line in your report) to the unit= form and also fixes a TypeError for multi-day intervals like "5d". So the specific lines you saw the warning on are addressed there. Thanks for pushing back on the version details — that's what surfaced it.
The PR replaces pandas Timedelta arithmetic on a Python date with the standard-library datetime.timedelta, updates the equivalent test code, and adds a deterministic regression test.
Thanks for the detailed investigation. I now understand that, with pandas 2.3.3 and NumPy 2.5.1, the keyword form itself can trigger the warning:
pd.Timedelta(days=548)
while the explicit-unit form does not:
pd.Timedelta(548, unit="D")
Your explicit (value, unit=...) approach makes sense for the interval-handling code in utils.py, where yfinance needs to construct pandas timedeltas from interval values.
For the FastInfo.shares line specifically, however:
pd.Timestamp.now("UTC").date()
already returns a Python datetime.date. Using:
datetime.timedelta(days=548)
keeps the calculation entirely within Python’s standard datetime types and avoids constructing a pandas/NumPy timedelta altogether.
I opened #2921 specifically to address the FastInfo.shares warning with this approach. Would you be open to removing the overlapping quote.py change from #2915 and keeping #2915 focused on:
Activity
DMZ22 commentedon Jul 22, 2026
Looked into this. The utils.py site was already reworked on dev in d8e2cfe (sub-day intervals now map to explicit units), and #2915 fixes the remaining quote.py site plus a TypeError regression d8e2cfe introduced for the "5d" interval.
One thing I could not do is reproduce the generic-unit warning itself — tried pandas 2.3.3/3.0.3 x numpy 2.4.6/2.5.1 on Python 3.11/3.12/3.14, all clean. Could you share your numpy version (
python -c "import numpy; print(numpy.__version__)")? Wondering if it needs a numpy dev build to trigger.andriy-git commentedon Jul 22, 2026
I know I didn't install any dev packages on this venv. Here are the versions I am using:
NumPy is version 2.5.1
Pandas is version 2.3.3
After bumping Pandas to version 3.0.3, I stopped getting the deprecation warning. So there is some incompatibility between Pandas and NumPy.
DMZ22 commentedon Jul 24, 2026
Thanks for the versions — that was the missing piece, and it let me reproduce it. My earlier "can't reproduce" was wrong: the trigger is numpy ≥ 2.5.0, and I had been testing against 2.4.6.
Built your exact stack (Python 3.14, numpy 2.5.1, pandas 2.3.3) and pinned it down. The warning has nothing to do with yfinance — it comes from inside pandas, on any
Timedeltaconstruction:No yfinance imported.
pd.Timedelta(days=1)does it too. The comparison and the subtraction in those two tracebacks are both clean — it is purely theTimedelta(...)call, soquote.py:254andutils.py:667are just the first two constructions a normal session happens to reach.Version matrix, all on Python 3.14:
So it is a pandas-2.x/numpy-2.5 incompatibility, exactly as your pandas bump suggested. Worth noting 2.3.3 is the final 2.x release, so that line will not be getting a fix — upgrading to pandas ≥ 3.0 is the only remedy.
One thing for the maintainers:
setup.pycurrently asks forpandas>=1.3.0andnumpy>=1.16.5, so pandas 2.3.3 + numpy 2.5.1 is a fully legal resolution of yfinance's own constraints and this will keep being reported. Might be worth either documenting it or requiringpandas>=3.0whennumpy>=2.5.Also flagging so this doesn't get closed by the wrong thing: #2915 is unrelated to this warning. It fixes a genuine
TypeErrorregression on the"5d"interval plus some date-arithmetic patterns, and it will not silence this deprecation — nothing in yfinance can, since the warning is raised before yfinance's own code gets involved.DMZ22 commentedon Jul 25, 2026
Small correction to what I said earlier. I claimed nothing in yfinance could silence this and only a pandas upgrade would — that's only half right.
The warning does come from inside pandas'
Timedeltaconstruction, so aTimedeltayou build yourself will still warn until pandas 3.0. But yfinance controls how it constructs the Timedeltas on the two lines from your traceback, and it turns out the construction form matters on this stack (numpy 2.5.1 / pandas 2.3.3):pd.Timedelta(days=548)andpd.Timedelta(minutes=90)— the keyword forms — still warnpd.Timedelta(548, unit="D")— the(value, unit=...)form — is silentThe existing workaround for #2882 used the keyword form, so it never actually suppressed the warning — its regression test fails on numpy 2.5.1. #2915 switches those sites (including
quote.py:254, the first line in your report) to theunit=form and also fixes aTypeErrorfor multi-day intervals like"5d". So the specific lines you saw the warning on are addressed there. Thanks for pushing back on the version details — that's what surfaced it.parthozyy commentedon Jul 25, 2026
I opened PR #2921 to address the remaining
FastInfo.shareswarning reported here:#2921
The PR replaces pandas
Timedeltaarithmetic on a Pythondatewith the standard-librarydatetime.timedelta, updates the equivalent test code, and adds a deterministic regression test.The targeted tests pass:
andriy-git commentedon Jul 25, 2026
This doesn't add anything, but you guys are on fire. The maintenance of this library is a well-oiled machine.
parthozyy commentedon Jul 25, 2026
@DMZ22
Thanks for the detailed investigation. I now understand that, with pandas 2.3.3 and NumPy 2.5.1, the keyword form itself can trigger the warning:
while the explicit-unit form does not:
Your explicit
(value, unit=...)approach makes sense for the interval-handling code inutils.py, where yfinance needs to construct pandas timedeltas from interval values.For the
FastInfo.sharesline specifically, however:already returns a Python
datetime.date. Using:keeps the calculation entirely within Python’s standard
datetimetypes and avoids constructing a pandas/NumPy timedelta altogether.I opened #2921 specifically to address the
FastInfo.shareswarning with this approach. Would you be open to removing the overlappingquote.pychange from #2915 and keeping #2915 focused on:_interval_to_timedeltautils.pyTypeErrorThat would give the two PRs separate scopes:
FastInfo.sharesI want our PRs to have different contributions so i am requesting you to remove the overlapping change
Pavankalyan32 commentedon Aug 13, 2026
Fix numpy>=2.5 generic-unit DeprecationWarning for interval parsing (r…
Fix numpy>=2.5 generic-unit DeprecationWarning for interval parsing (r…