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=' ')
pandas写入csv
最新推荐文章于 2024-08-07 19:38:10 发布
这篇博客介绍了如何利用pandas库在Python中删除包含特定内容的行,并将处理后的数据分别保存为train和val两个CSV文件。
摘要由CSDN通过智能技术生成