python Pandas 读取txt表格的实例
作者:bazingaedward 时间:2023-12-05 01:23:48
运行环境
Python 2.7
操作实例
1.原始文本格式:空格分隔的txt,例如
2016-03-22 00:06:24.4463094 中文测试字符
2016-03-22 00:06:32.4565680 需要编辑encoding
2016-03-22 00:06:32.6835965 abc
2016-03-22 00:06:32.8041945 egb
2.pandas 读取数据
import pandas as pd
data = pd.read_table('Z:/test.txt',header=None,encoding='gb2312',delim_whitespace=True,index_col=0)
#header=None:没有每列的column name,可以自己设定
#encoding='gb2312':其他编码中文显示错误
#delim_whitespace=True:用空格来分隔每行的数据
#index_col=0:设置第1列数据作为index
来源:https://blog.csdn.net/u011077672/article/details/50960580
标签:python,读取,txt,表格,Pandas
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
详解Hadoop 运行环境搭建过程
2022-08-25 13:50:58
pre标签自动换行
2009-03-13 13:37:00
php生成随机数/生成随机字符串的方法小结【5种方法】
2023-09-05 20:23:21
SQL Server 2005 FOR XML嵌套查询使用详解
2009-01-06 11:20:00
python中使用矢量化替换循环详解
2023-08-27 00:51:01
![](https://img.aspxhome.com/file/2023/1/99161_0s.png)
python自制简易mysql连接池的实现示例
2023-04-14 20:23:55
在 CSS 中关于字体处理效果的思考
2008-04-25 22:57:00
![](https://img.aspxhome.com/file/UploadPic/20071/2007131103237363s.gif)
Python新手们容易犯的几个错误总结
2021-06-22 12:19:54
![](https://img.aspxhome.com/file/2023/8/70118_0s.jpg)
支持PyTorch的einops张量操作神器用法示例详解
2023-10-17 23:13:06
Python-OpenCV教程之图像的位运算详解
2022-10-17 23:44:43
![](https://img.aspxhome.com/file/2023/9/93559_0s.png)
Go1.18新特性使用Generics泛型进行流式处理
2024-02-17 07:12:42
python多进程共享变量
2023-08-30 07:40:53
Python如何实现SSH远程连接与文件传输
2023-06-12 12:34:02
python 对dataframe下面的值进行大规模赋值方法
2022-01-08 07:04:19
mysql 8.0.12 安装配置方法并修改密码
2024-01-19 14:49:05
![](https://img.aspxhome.com/file/2023/3/119703_0s.jpg)
asp如何读取一个文件内容?
2009-11-19 17:23:00
Python OpenCV 直方图的计算与显示的方法示例
2022-10-15 07:36:24
![](https://img.aspxhome.com/file/2023/8/120938_0s.jpg)
用MySQL创建数据库和数据库表代码
2024-01-24 01:12:06
python 3.7.0 下pillow安装方法
2023-07-09 09:47:49
![](https://img.aspxhome.com/file/2023/6/80426_0s.png)
Python高效编程技巧
2023-08-19 17:29:56