Loading... > 这里提一下,pycharm运行的快捷键 shift+F10 # 读取csv ```python read_csv = pd.read_csv(filepath_or_buffer="../datas/ml-latest-small/ratings.csv") # 查看前几行 print(read_csv.head()) # 查看数据的形状,返回(行数,列数) print(read_csv.shape) # 查看列名列表 print(read_csv.columns) # 查看索引项 print(read_csv.index) # 查看每一列的数据类型 print(read_csv.dtypes) ``` # 读取txt ```python # 自己指定分隔符,列名 read_txt = pd.read_csv(filepath_or_buffer="../datas/crazyant/access_pvuv.txt", sep="\t", header=None, names=['pdate', 'pv', 'uv']) print(read_txt) ``` # 读取excel ```python read_excel = pd.read_excel("../datas/crazyant/access_pvuv.xlsx") print(read_excel) ``` # 读取mysql ```python import pymysql conn = pymysql.connect( host="127.0.0.1", user="root", password="12345678", database="test", charset="utf8" ) read_mysql = pd.read_sql('select * from crazyan_pvuv', con=conn) print(read_mysql) ``` <div class="tip inlineBlock error"> 对应文档 </div> <div class="hideContent">此处内容需要评论回复后(审核通过)方可阅读。</div> 最后修改:2022 年 12 月 13 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏