Open Pmica opened 10 months ago
I get the following error:
TypeError Traceback (most recent call last) Cell In[30], line 1 ----> 1 qs.plots.snapshot(df, title='Performance', show=True)
File ~\AppData\Local\anaconda3\Lib\site-packages\quantstats_plotting\wrappers.py:90, in snapshot(returns, grayscale, figsize, title, fontname, lw, mode, subtitle, savefig, show, log_scale, *kwargs) 88 returns = returns.mean(axis=1) 89 title = title + " (daily equal-weighted)" ---> 90 returns.columns = strategy_colname 92 colors = _GRAYSCALE_COLORS if grayscale else _FLATUI_COLORS 93 returns = _utils.make_portfolio(returns.dropna(), 1, mode).pct_change().fillna(0)
File ~\AppData\Local\anaconda3\Lib\site-packages\pandas\core\generic.py:6002, in NDFrame.setattr(self, name, value) 6000 try: 6001 object.getattribute(self, name) -> 6002 return object.setattr(self, name, value) 6003 except AttributeError: 6004 pass
File ~\AppData\Local\anaconda3\Lib\site-packages\pandas_libs\properties.pyx:69, in pandas._libs.properties.AxisProperty.set()
File ~\AppData\Local\anaconda3\Lib\site-packages\pandas\core\generic.py:729, in NDFrame._set_axis(self, axis, labels)
723 @final
724 def _set_axis(self, axis: AxisInt, labels: AnyArrayLike | list) -> None:
725 """
726 This is called from the cython code when we set the index
attribute
727 directly, e.g. series.index = [1, 2, 3]
.
728 """
--> 729 labels = ensure_index(labels)
730 self._mgr.set_axis(axis, labels)
731 self._clear_item_cache()
File ~\AppData\Local\anaconda3\Lib\site-packages\pandas\core\indexes\base.py:7128, in ensure_index(index_like, copy) 7126 return Index(index_like, copy=copy, tupleize_cols=False) 7127 else: -> 7128 return Index(index_like, copy=copy)
File ~\AppData\Local\anaconda3\Lib\site-packages\pandas\core\indexes\base.py:516, in Index.new(cls, data, dtype, copy, name, tupleize_cols) 513 data = com.asarray_tuplesafe(data, dtype=_dtype_obj) 515 elif is_scalar(data): --> 516 raise cls._raise_scalar_data_error(data) 517 elif hasattr(data, "array"): 518 return Index(np.asarray(data), dtype=dtype, copy=copy, name=name)
File ~\AppData\Local\anaconda3\Lib\site-packages\pandas\core\indexes\base.py:5066, in Index._raise_scalar_data_error(cls, data) 5061 @final 5062 @classmethod 5063 def _raise_scalar_data_error(cls, data): 5064 # We return the TypeError so that we can raise it from the constructor 5065 # in order to keep mypy happy -> 5066 raise TypeError( 5067 f"{cls.name}(...) must be called with a collection of some " 5068 f"kind, {repr(data)} was passed" 5069 )
TypeError: Index(...) must be called with a collection of some kind, 'Strategy' was passed
Hi @Pmica, have a look at #313 (similar question regarding csv returns import), let me know if that helps!
Has anyone tried to load strategy returns data from csv successfully. How have you done this, what format/ structure should it take. I haven’t successfully managed to do it without an error