Join GitHub today
TypeError in Cython with tuple subclasses in DataFrame.from_records #611
From user email
Just a quick bug report. I'm using psycopg2 with a NamedTupleCursor, which returns namedtuples for rows. I'm trying to use DataFrame.from_records like so:
df = DataFrame.from_records(rows, rows._fields)
I get the following error:
So it looks like in tseries.c it's doing something like "type(row) == tuple" instead of "isinstance(row, tuple)". For what it's worth, "isinstance(rows, tuple)" is true, so the tuples returned by psycopg2 are definitely real namedtuples. Additionally, the following works fine:
So there's no problem with the data, or with DataFrame, just the type check in tseries.c.
Let me know if I can provide any more information! Thanks.