数据读取
1.纯文本读取
import pandas as pd
fpath = "xxx"
datas = pd.read_csv(fpath)
print(datas.head(n))
print(datas.shape())
print(datas.index)
print(datas.dtypes)
fpath = "xxx"
datas = pd.read_cvs(fpath,
sep="xxx",
names = ["xxx","xxx"...]
)
2.从excel表中读取
import pandas as pd
fpath = "xxx"
excelData = pd.read_excel(fpath)
print(excel)
3.从Mysql数据库读取
import pandas as pd
import pymysql
conn = pymysql.connect(
host="url",
user="用户名",
password="密码",
database="数据库名",
charset="编码(例如utf8)"
)
MysqlData = pd.read_sql("查询语句(例如select * from student)",con=conn)
print(MysqlData)