Open SergeyHein opened 1 week ago
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 https://github.com/Lumiwealth/quantstats_lumi/issues/61, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIYQK6BZH2G7ZADT2BUA5LZZWECZAVCNFSM6AAAAABPKLEH4OVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU3DINZRHAYDIOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@grzesir here you go https://github.com/Lumiwealth/quantstats_lumi/pull/62
Setup
Error
I'm receiving error when calling
qs.reports.full
Root cause
returns.min()
is a Series whereasbenchmark.min()
is a floatProposed solution