python 利用pandas将arff文件转csv文件的方法
作者:lonely_square_three 时间:2021-05-31 05:49:34
直接贴代码啦:
#coding=utf-8
import pandas as pd
def arff_to_csv(fpath):
#读取arff数据
if fpath.find('.arff') <0:
print('the file is nott .arff file')
return
f = open(fpath)
lines = f.readlines()
content = []
for l in lines:
content.append(l)
datas = []
for c in content:
cs = c.split(',')
datas.append(cs)
#将数据存入csv文件中
df = pd.DataFrame(data=datas,index=None,columns=None)
filename = fpath[:fpath.find('.arff')] + '.csv'
df.to_csv(filename,index=None)
来源:https://blog.csdn.net/xzfreewind/article/details/79587726
标签:python,pandas,arff,csv
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python爬虫实战之虎牙视频爬取附源码
2021-04-02 01:23:27
![](https://img.aspxhome.com/file/2023/9/64269_0s.png)
python读取和保存图片5种方法对比
2022-05-27 23:54:32
Oracle 存储过程加密方法
2009-10-23 18:02:00
Python爬虫+Tkinter制作一个翻译软件的示例
2023-12-14 07:22:42
![](https://img.aspxhome.com/file/2023/0/82890_0s.png)
Internet Explorer 8 Beta2 功能预览
2008-07-29 13:20:00
![](https://img.aspxhome.com/file/UploadPic/20087/29/2008729132347173s.jpg)
python政策网字体反爬实例(附完整代码)
2021-04-27 19:51:32
![](https://img.aspxhome.com/file/2023/1/93751_0s.jpg)
Python办公自动化从Excel中计算整理数据并写入Word
2021-12-19 03:22:35
![](https://img.aspxhome.com/file/2023/9/97409_0s.png)
python调用cmd命令行制作刷博器
2023-07-26 15:18:35
用Python进行一些简单的自然语言处理的教程
2021-07-03 19:51:26
Python如何输出整数
2022-03-30 07:19:35
![](https://img.aspxhome.com/file/2023/4/100944_0s.png)
浅谈django channels 路由误导
2021-12-11 00:27:09
![](https://img.aspxhome.com/file/2023/1/103471_0s.png)
前端开发中一些常用技巧总结
2010-07-18 13:13:00
深入探讨opencv图像矫正算法实战
2022-06-03 16:20:39
![](https://img.aspxhome.com/file/2023/8/102858_0s.jpg)
Python基于Google Bard实现交互式聊天机器人
2022-12-14 22:05:20
![](https://img.aspxhome.com/file/2023/1/70081_0s.png)
python项目报错:bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requests
2022-07-17 05:39:02
![](https://img.aspxhome.com/file/2023/4/92114_0s.jpg)
python matplotlib绘图实现删除重复冗余图例的操作
2023-11-02 22:36:44
使用pytorch进行张量计算、自动求导和神经网络构建功能
2022-08-18 11:50:48
windows、linux下打包Python3程序详细方法
2023-09-30 22:06:53
![](https://img.aspxhome.com/file/2023/0/62930_0s.png)
Ubuntu下设置mysql自动备份
2010-10-25 20:25:00
ASP利用XMLHTTP实现表单提交以及cookies的发送的代码
2011-04-15 10:37:00