import pandas as pd
import pymysql
#1.处理数据格式
csvpath=r"Y:WorkplaceBigDatapercent-bachelors-degrees-women-usa.csv" food=pd.read_csv(csvpath)#路径必须全英文 print(food.head(5) ) csvpath2=r"Y:WorkplaceBigData2019.csv" food=pd.read_table(csvpath2,encode="utf-8")#指定编码。知道编码 print(food.head(5) )
#2.链接数据库 #myd格式用Mysql处理 conn=pymysql.connect(host="127.0.0.1",user="root",password="123456",db="testjdbc") sql="select * from t_user where id < 1000" df=pd.read_sql_query(sql,conn) print(df)