import pandas as pd
#读csv xls
df=pd.read_csv('D:\\Anaconda3\\A\\1.csv',encoding='gbk')
df1=pd.read_excel('D:\\Anaconda3\\A\\1.xls',encoding='gbk')
print(df,df1)
#list转pd数据框
my_list=[('xiaoming','11'),('wang','22')]
df=pd.DataFrame(my_list,columns=['name','age'])
#插入mysql数据库 test是库名 xxx是表名 root:123mysql是账号密码
# pip install pymysql
# pip install mysql-connector-python
from sqlalchemy import create_engine
from sqlalchemy.types import *
df=pd.DataFrame({"班级":["一年级","二年级"],
"男生人数":[11,14],
"女生人数":[10,15]})
engin=create_engine('mysql+mysqlconnector://root:[email protected]:3306/test')
df.to_sql("xxx",engin)
#打印数据框行列 df.shape
#打印数据框列名 df.columns
#打印索引
#打印数据类型
#打印数据摘要
#打印行
#iloc打印列
标签:df,打印,list,笔记,pd,mysql,import,pandas From: https://www.cnblogs.com/hanxing/p/17500971.html