Data Science Asked by Paijo S Kom on June 4, 2021
I am new using pandas.
I am asking about how to insert specific columns using to_sql.
This is my explanation.
I have a database with a table datasiswa with columns:
And I have an excel file with header name and age.
How to use to_sql to insert in fields name and age only, without ids.
You'll need to perform two steps:
You get ride of the id column in the pandas dataframe:
df=df.drop(columns=['id'])
Add the index=False
param: to the .to_sql()
method:
selected.to_sql('dataiswa', engine, index=False)
Answered by Hernán Borré on June 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP