-
Notifications
You must be signed in to change notification settings - Fork 32
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
plot_timeseries does not handle types properly in Python 3.12 #61
Comments
Please submit a pull request and I can merge it in
Robert Grzesik 347-635-3416
…On Thu, Oct 3, 2024 at 2:27 PM SergeyHein ***@***.***> wrote:
*Setup*
- quantstats_lumi 0.3.3
- pandas 2.2.3
- python 3.12
- OS WSL / Ubuntu-24.04
*Error*
I'm receiving error when calling qs.reports.full
/******************-s8VZZPBo-py3.12/lib/python3.12/site-packages/quantstats_lumi/_plotting/core.py in ?(returns, benchmark, title, compound, cumulative, fill, returns_label, hline, hlw, hlcolor, hllabel, percent, match_volatility, log_scale, resample, lw, figsize, ylabel, grayscale, fontname, subtitle, savefig, show)
357 # Set y-axis limits to avoid blank space at the bottom and top
358 min_val = returns.min()
359 max_val = returns.max()
360 if benchmark is not None:
--> 361 min_val = min(min_val, benchmark.min())
362 max_val = max(max_val, benchmark.max())
363 ax.set_ylim(bottom=min_val, top=max_val)
364
/******************-s8VZZPBo-py3.12/lib/python3.12/site-packages/pandas/core/generic.py in ?(self)
1575 @Final
1576 def __nonzero__(self) -> NoReturn:
-> 1577 raise ValueError(
1578 f"The truth value of a {type(self).__name__} is ambiguous. "
1579 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
1580 )
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
*Root cause*
returns.min() is a Series whereas benchmark.min() is a float
*Proposed solution*
# Set y-axis limits to avoid blank space at the bottom and top
min_val = returns.min()
max_val = returns.max()
if isinstance(returns, _pd.DataFrame):
min_val = min_val.iloc[0]
max_val = max_val.iloc[0]
if benchmark is not None:
min_val = min(min_val, benchmark.min())
max_val = max(max_val, benchmark.max())
—
Reply to this email directly, view it on GitHub
<#61>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIYQK6BZH2G7ZADT2BUA5LZZWECZAVCNFSM6AAAAABPKLEH4OVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU3DINZRHAYDIOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup
Error
I'm receiving error when calling
qs.reports.full
Root cause
returns.min()
is a Series whereasbenchmark.min()
is a floatProposed solution
The text was updated successfully, but these errors were encountered: