#数据导入
#导入csv文件
from pandas import read_csv
ak=read_csv('D://Python projects//reference data//4.1 数据导入//1.csv')
#导入txt文件
#无表头版
from pandas import read_table
ar=read_table('D://Python projects//reference data//4.1 数据导入//2.txt')
#自定义表头版
ap=read_table('D://Python projects//reference data//4.1 数据导入//2.txt',
names=['age','name'],
sep=',')
#导入excel
from pandas import read_excel
aw=read_excel('D://Python projects//reference data//4.1 数据导入//3.xlsx',
sheetname='data')
#中文问题
from pandas import read_table
file_path='D://Python projects//reference data//4.1 数据导入//中文.txt'
am=read_table(
file_path,
sep=',',
encoding='utf-8')
#可通过engine='python'解决
fro
python的导入与导出
最新推荐文章于 2024-06-27 17:55:30 发布
这篇博客介绍了如何在Python中使用pandas库进行数据导入,包括读取csv、txt、excel文件,处理中文问题,以及数据导出为csv文件的方法。
摘要由CSDN通过智能技术生成