Mysqldb Query To Numpy Array
So I've tried to follow What's the most efficient way to convert a MySQL result set to a NumPy array? but am still having problems. My database rows are 57 unsigned integers (Unix
Solution 1:
np.fromiter
is complaining because it is trying to write a full row of inputs into a single item of the new array. You can work around this using record arrays:
A = numpy.fromiter(cursor.fetchall(), count=-1,
dtype=[('', numpy.uint8)]*57)
If all your records are of the same type, you can then get an array view as follows:
A = A.view(numpy.uint8).reshape(-1, 57)
Post a Comment for "Mysqldb Query To Numpy Array"