当前位置: 移动技术网 > IT编程>脚本编程>Python > python将pandas datarame保存为txt文件的实例

python将pandas datarame保存为txt文件的实例

2019年03月18日  | 移动技术网IT编程  | 我要评论

吴邪伪春菜,罗通拜师,北京摸吧

csv means comma separated values. it is plain text (ansi).

the csv ("comma separated value") file format is often used to exchange data between disparate applications. the file format, as it is used in microsoft excel, has become a pseudo standard throughout the industry, even among non-microsoft platforms.

txt is not really a file format, and it could mean multiple things in different contexts. generally you export tables in either csv (comma separated values) or tsv (tab separated values). which you should choose depends mainly on your data: if your data has commas in it but not tabs, you should go for tsv.

# -*- coding: utf-8 -*-
import sys
import json
reload(sys)
sys.setdefaultencoding('utf-8')
 
import pandas as pd
import numpy as np
 
 
#读取excel保存成txt格式
excel_file = pd.read_excel("text.xlsx")
excel_file.to_csv('excel2txt.txt', sep='\t', index=false)

参考:https://stackoverflow.com/questions/41428539/data-frame-to-file-txt-python/41514539

以上这篇python将pandas datarame保存为txt文件的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网