在python中将数据加载到SQLalchemy时忽略索引列

2024-04-25 21:13:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我想删除图片上的索引列,它已经删除了。我想去掉这两个。我的想法是使用index\u ignore=True,但不确定放在哪里。你知道吗

screenshot index column, SQLalchemy in python

import pandas as pd
from sqlalchemy import create_engine

db_file = r'learn-data-analysis-w-python-master/datasets/salesdata.db'

engine = create_engine(r'sqlite:///{}'.format(db_file))
sql = 'SELECT * from scores'
sales_data_df = pd.read_sql(sql, engine)
sales_data_df

Tags: fromimporttruedfdbsqldataindex