omdv / robinhood-portfolio

DEPRECATED. Portfolio analyzer for Robinhood accounts
MIT License
80 stars 29 forks source link

cannot set using a list-like indexer with a different length than the value #12

Closed XiyanHu closed 3 years ago

XiyanHu commented 4 years ago

Hi, I am using Jupyter notebook locally and got an error : ValueError: cannot set using a list-like indexer with a different length than the value. Detailed logs here. Thanks!


ValueError Traceback (most recent call last)

in 1 # main calculations section ----> 2 ptf = PortfolioModels('data') 3 summary = ptf.portfolio_summary() 4 stocks = ptf.stocks_risk() 5 df_corr, df_cov = ptf.stocks_correlation() ~/Documents/robinhood-portfolio/backend/portfolio_models.py in __init__(self, datafolder) 15 self.datafolder = datafolder 16 self._daily = None ---> 17 self._calculate_daily() 18 return None 19 ~/Documents/robinhood-portfolio/backend/portfolio_models.py in _calculate_daily(self) 153 154 # merge orders with market --> 155 pf = self._merge_market_with_dividends(df, pf) 156 157 # replace null stock prices using backfill to avoid issues with ~/Documents/robinhood-portfolio/backend/portfolio_models.py in _merge_market_with_dividends(self, df_div, mkt) 81 df['cum_dividends'].fillna(0, inplace=True) 82 ---> 83 mkt.loc[_symbol] = df.values 84 85 return mkt ~/Documents/robinhood-portfolio/robinhood/lib/python3.7/site-packages/pandas/core/indexing.py in __setitem__(self, key, value) 668 669 iloc = self if self.name == "iloc" else self.obj.iloc --> 670 iloc._setitem_with_indexer(indexer, value) 671 672 def _validate_key(self, key, axis: int): ~/Documents/robinhood-portfolio/robinhood/lib/python3.7/site-packages/pandas/core/indexing.py in _setitem_with_indexer(self, indexer, value) 1800 # actually do the set 1801 self.obj._consolidate_inplace() -> 1802 self.obj._mgr = self.obj._mgr.setitem(indexer=indexer, value=value) 1803 self.obj._maybe_update_cacher(clear=True) 1804 ~/Documents/robinhood-portfolio/robinhood/lib/python3.7/site-packages/pandas/core/internals/managers.py in setitem(self, indexer, value) 532 533 def setitem(self, indexer, value) -> "BlockManager": --> 534 return self.apply("setitem", indexer=indexer, value=value) 535 536 def putmask( ~/Documents/robinhood-portfolio/robinhood/lib/python3.7/site-packages/pandas/core/internals/managers.py in apply(self, f, align_keys, **kwargs) 404 applied = b.apply(f, **kwargs) 405 else: --> 406 applied = getattr(b, f)(**kwargs) 407 result_blocks = _extend_blocks(applied, result_blocks) 408 ~/Documents/robinhood-portfolio/robinhood/lib/python3.7/site-packages/pandas/core/internals/blocks.py in setitem(self, indexer, value) 852 853 # length checking --> 854 check_setitem_lengths(indexer, value, values) 855 exact_match = ( 856 len(arr_value.shape) ~/Documents/robinhood-portfolio/robinhood/lib/python3.7/site-packages/pandas/core/indexers.py in check_setitem_lengths(indexer, value, values) 150 ): 151 raise ValueError( --> 152 "cannot set using a list-like indexer " 153 "with a different length than the value" 154 ) ValueError: cannot set using a list-like indexer with a different length than the value
omdv commented 4 years ago

@XiyanHu, alright, thanks for reporting. I just found out that Robinhood changed their API, but looks like you had issue before that. Will need few days - very busy at work/home this days.

XiyanHu commented 4 years ago

Thanks for the reply, absolutely no hurry :)

omdv commented 3 years ago

As you can imagine I didn't have a chance to look at it. Apologies. Will have to deprecate it. Feel free to salvage what you can.