dataframe into txt and csv file

The dataframe files into txt and csv, but also can convert other file format to dataframe then converted to txt file, in short, to try

type(file)
#file为我的文件名称
#将文件导出为txt
import sys
import json
import pandas as pd
import numpy as np
#index=false表示导出的时候没有index这个属性
file.to_csv('threecolumn.txt',sep='\t',index=False)
#将文件导出为csv,不设置index=false表示有index这个属性
file.to_csv('threecolumn1.csv')

txt format
Here Insert Picture Description
csv format
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_42542536/article/details/88824775