quantopian / pyfolio

Portfolio and risk analytics in Python
https://quantopian.github.io/pyfolio
Apache License 2.0
5.63k stars 1.77k forks source link

linear regression ---- printing vlues in dataframe #593

Open sairamdgr8 opened 5 years ago

sairamdgr8 commented 5 years ago

ValueError Traceback (most recent call last) C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals.py in create_block_manager_from_blocks(blocks, axes) 4621 blocks = [make_block(values=blocks[0], -> 4622 placement=slice(0, len(axes[0])))] 4623

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals.py in make_block(values, placement, klass, ndim, dtype, fastpath) 2956 -> 2957 return klass(values, ndim=ndim, fastpath=fastpath, placement=placement) 2958

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals.py in init(self, values, placement, ndim, fastpath) 119 'implies %d' % (len(self.values), --> 120 len(self.mgr_locs))) 121

ValueError: Wrong number of items passed 5, placement implies 1

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)

in () ----> 1 ddf=pd.DataFrame(lm.coef_,X.columns,columns=['coeffs']) C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in __init__(self, data, index, columns, dtype, copy) 359 else: 360 mgr = self._init_ndarray(data, index, columns, dtype=dtype, --> 361 copy=copy) 362 elif isinstance(data, (list, types.GeneratorType)): 363 if isinstance(data, types.GeneratorType): C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in _init_ndarray(self, values, index, columns, dtype, copy) 531 values = maybe_infer_to_datetimelike(values) 532 --> 533 return create_block_manager_from_blocks([values], [columns, index]) 534 535 @property C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals.py in create_block_manager_from_blocks(blocks, axes) 4629 blocks = [getattr(b, 'values', b) for b in blocks] 4630 tot_items = sum(b.shape[0] for b in blocks) -> 4631 construction_error(tot_items, blocks[0].shape[1:], axes, e) 4632 4633 C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals.py in construction_error(tot_items, block_shape, axes, e) 4606 raise ValueError("Empty data passed with indices specified.") 4607 raise ValueError("Shape of passed values is {0}, indices imply {1}".format( -> 4608 passed, implied)) 4609 4610 ValueError: Shape of passed values is (5, 1), indices imply (1, 5) _Originally posted by @sairamdgr8 in https://github.com/quantopian/pyfolio/issues/449#issuecomment-470672363_
twiecki commented 5 years ago

There is no reference to where in the code this actually happens or what function you called.