from pandas import DataFrame
import pyodbc
cnxn = pyodbc.connect(databasez)
cursor.execute("""SELECT ID, NAME AS Nickname, ADDRESS AS Residence FROM tablez""")
DF = DataFrame(cursor.fetchall())
This is fine to populate my pandas DataFrame. But how do I get
DF.columns = ['ID', 'Nickname', 'Residence']
straight from cursor? Is that information stored in cursor at all?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…