Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

python 3.x - Creating a table based on a Pandas dataframe

import pandas as pd
data = pd.DataFrame({ 'id' : [1,2,3,4], 'text' : ['Sample1', 'Sample2', 'Sample3', 'Sample4'] })
data                                                                                                                                                                                                                                        
    id     text                                                                                                          
0   1  Sample1                                                                                                         
1   2  Sample2                                                                                                          
2   3  Sample3                                                                                                          
3   4  Sample4 

I have a dataframe created in a python program. I am using psycopg2 to connect to a Postgres database. Is there any way I can directly create a table in postgres using this dataframe in python as a reference?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...