Skip to content
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

UnsupportedFunctionCall #376

Open
bbalouki opened this issue Oct 27, 2024 · 5 comments
Open

UnsupportedFunctionCall #376

bbalouki opened this issue Oct 27, 2024 · 5 comments

Comments

@bbalouki
Copy link

qs.reports.full(returns, mode='full', benchmark=benchmark)
File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\quantstats\reports.py", line 628, in full
plots(
File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\quantstats\reports.py", line 1346, in plots
_plots.daily_returns(
File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\quantstats_plotting\wrappers.py", line 512, in daily_returns
fig = _core.plot_timeseries(
File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\quantstats_plotting\core.py", line 294, in plot_timeseries
returns = returns.last() if compound is True else returns.sum(axis=0)
File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\pandas\core\resample.py", line 1183, in sum
nv.validate_resampler_func("sum", args, kwargs)
File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\pandas\compat\numpy\function.py", line 376, in validate_resampler_func
raise UnsupportedFunctionCall(
pandas.errors.UnsupportedFunctionCall: numpy operations are not valid with resample. Use .resample(...).sum() instead

@julienwagener
Copy link

Same problem here...

@yaping19
Copy link

I also encountered the same issue, the code was working fine previously but suddenly gives below error when I try to create a html report. Not sure if it coincide with recent yahoodownloader update, but hopefully a solution can be found soon
image

@KingTurbo
Copy link

To fix the resampling issue in the quantstats library, locate the "core.py" file in the quantstats installation directory (usually found in your Python site-packages).

Around line 292, replace the existing code with the following:

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

I haven't tested the entire repo, but when I call full() it works. :)

@JomaDeveloper
Copy link

It was issued by brunch in "Issues" #375.

@subinoy
Copy link

subinoy commented Nov 7, 2024

Still there are some issues as below
../miniforge3/envs/fin12/lib/python3.12/site-packages/quantstats/_plotting/core.py:1016: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

port["Weekly"].ffill(inplace=True)
../miniforge3/envs/fin12/lib/python3.12/site-packages/quantstats/_plotting/core.py:1019: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

port["Monthly"].ffill(inplace=True)
../miniforge3/envs/fin12/lib/python3.12/site-packages/quantstats/_plotting/core.py:1022: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

port["Quarterly"].ffill(inplace=True)
../miniforge3/envs/fin12/lib/python3.12/site-packages/quantstats/_plotting/core.py:1025: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

port["Yearly"].ffill(inplace=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants