新聞中心
這篇文章將為大家詳細(xì)講解有關(guān)python中怎么將pandas和datarame保存為txt文件,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。
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)
關(guān)于python中怎么將pandas和datarame保存為txt文件就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
文章名稱(chēng):python中怎么將pandas和datarame保存為txt文件-創(chuàng)新互聯(lián)
當(dāng)前鏈接:http://fisionsoft.com.cn/article/gghgo.html