pandas写入csv

这篇博客介绍了如何利用pandas库在Python中删除包含特定内容的行,并将处理后的数据分别保存为train和val两个CSV文件。
摘要由CSDN通过智能技术生成
import pandas as pd
write_csv = "train.csv"
"""处理待存数据frame, xmin, xmax, ymin, ymax为list格式"""
column_frame = pd.Series(frame, name='frame')
column_xmin = pd.Series(xmin, name='xmin')
column_xmax = pd.Series(xmax, name='xmax')
column_ymin = pd.Series(ymin, name='ymin')
column_ymax = pd.Series(ymax, name='ymax')
column_classid = pd.Series(class_id, name='class_id')

save = pd.DataFrame({'frame':frame, 'xmin':xmin, 'xmax':xmax, 'ymin':ymin, 'ymax':ymax, 'class_id':class_id})
save.to_csv(write_csv, index=False, sep=' ')  
"""上面这种方法,列的顺序和设定的不同"""

con = pd.concat([column_frame, column_xmin, column_xmax, column_ymin, column_ymax, column_classid], axis=1)
con.to_csv("train2.csv", index=False, sep=' ')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值