I ran this notebook for a few specific dates by making the following alteration (for example):
today = datetime.datetime(2014,7,1,12,1,0)
and then running the rest of the notebook as-is.
This worked fine for a number of time periods, but not for any where I used January first.
For example, when I ran it using today = datetime.datetime(2014,1,1,12,1,0) I got the error below:
Could the OP or someone else investigate this. I apologize, but I know almost nothing about python so I can't fix this myself.
Thanks so much!
exret = (np.log(returns.add(1))).sub(np.log(returns_sp.add(1)).as_matrix())
exret
ValueError Traceback (most recent call last)
in ()
----> 1 exret = (np.log(returns.add(1))).sub(np.log(returns_sp.add(1)).as_matrix())
2 exret
/usr/local/lib/python2.7/dist-packages/pandas/core/ops.pyc in f(self, other, axis, level, fill_value)
1079 # casted = self.constructor_sliced(other,
1080 # index=self.columns)
-> 1081 casted = pd.Series(other, index=self.columns)
1082 return self.combine_series(casted, na_op, fill_value, axis,
1083 level)
/usr/local/lib/python2.7/dist-packages/pandas/core/series.pyc in init(self, data, index, dtype, name, copy, fastpath)
227 raise_cast_failure=True)
228
--> 229 data = SingleBlockManager(data, index, fastpath=True)
230
231 generic.NDFrame.init(self, data, fastpath=True)
/usr/local/lib/python2.7/dist-packages/pandas/core/internals.pyc in init(self, block, axis, do_integrity_check, fastpath)
3815 if not isinstance(block, Block):
3816 block = make_block(block, placement=slice(0, len(axis)), ndim=1,
-> 3817 fastpath=True)
3818
3819 self.blocks = [block]
/usr/local/lib/python2.7/dist-packages/pandas/core/internals.pyc in make_block(values, placement, klass, ndim, dtype, fastpath)
2516 placement=placement, dtype=dtype)
2517
-> 2518 return klass(values, ndim=ndim, fastpath=fastpath, placement=placement)
2519
2520 # TODO: flexible with index=None and/or items=None
/usr/local/lib/python2.7/dist-packages/pandas/core/internals.pyc in init(self, values, placement, ndim, fastpath)
88 raise ValueError('Wrong number of items passed %d, placement '
89 'implies %d' % (len(self.values),
---> 90 len(self.mgr_locs)))
91
92 @property
ValueError: Wrong number of items passed 3, placement implies 4