[Numpy-discussion] ValueError: objects are not aligned

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Sep 8 07:09:46 EDT 2010


On Wed, Sep 8, 2010 at 5:42 AM, RuiDC <ruidc at yahoo.com> wrote:
>
> I'm getting this error, which must be a simple error in getting the result
> from the cursor in the right shape, how do I get the cursor into the array
> as a single dimension?:
>
>    import numpy as np
>    import sqlite3
>    conn = sqlite3.connect("simpledb")
>    cursor1 = conn.execute("select LogReturn from tblReturns limit 3")
>    rf1 = np.asarray(cursor1.fetchall(), dtype=np.float64)
>    print (rf1)
>    print (np.corrcoef([rf1, rf1]))

numpy.corrcoef(x, y=None, rowvar=1, bias=0)

try
np.corrcoef(rf1, rf1, rowvar=0)   no [ ]
or
stacking rf1 rf1 into a single array first

Josef

>
> result:
> [[-0.00641625]
>  [-0.00498411]
>  [-0.0038015 ]]
> Traceback (most recent call last):
>  File "C:\Documents and Settings\rui\workspace\numpytest\src\numpytest.py",
> line 38, in <module>
>    print (np.corrcoef([rf1, rf1]))
>  File "C:\Python26\lib\site-packages\numpy\lib\function_base.py", line
> 2003, in corrcoef
>    c = cov(x, y, rowvar, bias, ddof)
>  File "C:\Python26\lib\site-packages\numpy\lib\function_base.py", line
> 1953, in cov
>    return (dot(X, X.T.conj()) / fact).squeeze()
> --
> View this message in context: http://old.nabble.com/ValueError%3A-objects-are-not-aligned-tp29641661p29641661.html
> Sent from the Numpy-discussion mailing list archive at Nabble.com.
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list