我已經下載了一些數據作爲sqlite數據庫(data.db),我想在python中打開這個數據庫,然後將其轉換爲熊貓數據框。如何打開並將sqlite數據庫轉換爲熊貓數據框
這是迄今爲止我已經做
import sqlite3
import pandas
dat = sqlite3.connect('data.db') #connected to database with out error
pandas.DataFrame.from_records(dat, index=None, exclude=None, columns=None, coerce_float=False, nrows=None)
但其引發此錯誤
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 980, in from_records
coerce_float=coerce_float)
File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 5353, in _to_arrays
if not len(data):
TypeError: object of type 'sqlite3.Connection' has no len()
如何轉換SQLite數據庫,以大熊貓數據幀