quantstats icon indicating copy to clipboard operation
quantstats copied to clipboard

FutureWarning: Errors & Unsupported Function in Pandas

Open rriggin opened this issue 1 year ago • 4 comments

I'm getting the following errors

 FutureWarning: Passing additional kwargs to DatetimeIndexResampler.sum has no impact on the result and is deprecated. This will raise a TypeError in a future version of pandas.

  pandas.errors.UnsupportedFunctionCall: numpy operations are not valid with resample. Use .resample(...).sum() instead

When I try to run this code:

import quantstats as qs

qs.extend_pandas()

stock = qs.utils.download_returns('GLD')

qs.reports.html(stock, title='GLD Report', output='output/gld_report.html')

qs.reports.html(stock, "ASML", title='GLD vs ASML Report', output='output/asml_vs_gld.html')

Full Error String

CleanShot 2024-12-28 at 16 12 50@2x

rriggin avatar Dec 28 '24 22:12 rriggin

same here

renanmoretto avatar Jan 06 '25 23:01 renanmoretto

I got the same error, couldn't fina a solution...

emonares avatar Jan 16 '25 19:01 emonares

same error for me,

What I have tried so far:

pip install quantstats --upgrade

returns = returns.resample(resample).last() if compound is True else returns.resample(resample).sum() Modified core.py (line 294) as suggested

pip install numpy==1.24.4 pandas==1.3.5 Downgrade

Jerem7401 avatar Feb 03 '25 22:02 Jerem7401

Change this to https://github.com/ranaroussi/quantstats/blob/fc7b1bf3788ac64b0c58cc69fae435eddbd21b02/quantstats/_plotting/core.py#L292

if resample:
        returns = returns.last() if compound is True else returns.resample(resample).sum(min_count=1)
        if isinstance(benchmark, _pd.Series):
            benchmark = benchmark.resample(resample)
            benchmark = benchmark.last() if compound is True else benchmark.sum(axis=0)

NitinDatta8 avatar Feb 18 '25 19:02 NitinDatta8

Closing this issue as it's older than 2025 and has been addressed in the latest release 0.0.64. The pandas compatibility issues mentioned in this issue have been resolved with the comprehensive compatibility layer implemented in the latest version.

ranaroussi avatar Jul 18 '25 14:07 ranaroussi