DataFrame 写入文件

df.to_csv( '/Users/tlx/PythonFile/DCDB_659.txt' , sep= ',' , header=False, index=False)

不写入 行索引(index),列索引(header)

df.to_csv( '/Users/tlx/PythonFile/DCDB_659.csv' , sep= ',' , header=True, index=True)

写入 行索引(index),列索引(header)

注:写入文件可以是 .csv 也可以是 .txt

你可能感兴趣的:(python学习,python,机器学习,pandas)