1.数据读取
import pandas as pd
pd.options.display.max_columns=None
pd.set_option("display.unicode.east_asian_width",True)
data=pd.read_excel("./titanic3.xls",sheet_name="titanic3")
print(data.head())
data1=pd.read_csv("./BeijingPM2.5.csv",sep=",",encoding="utf-8",index_col=["No"])
data2=pd.read_csv("./BeijingPM2.5_new.csv",sep=",",encoding="utf-8",header=None)
print(data1.head())
print(data2.head())
2.数据的写入
3.数据库sqlalchemy
engine=create_engine("mysql+pymysql://root:123456@127.0.0.1:3306/taitannic?charset=utf8mb4")
data.to_sql("my_taitannic",con=engine,if_exists="replace",index=False)
data3=pd.read_sql_table("my_taitannic",con=engine)
data4=pd.read_sql_query("select * from my_taitannic ")
data5=pd.read_sql()