python將pandas datarame保存為txt文件的實(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)
參考:https://stackoverflow.com/questions/41428539/data-frame-to-file-txt-python/41514539
以上這篇python將pandas datarame保存為txt文件的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
深入了解python的tkinter實(shí)現(xiàn)簡(jiǎn)單登錄
這篇文章主要為大家介紹了python的tkinter實(shí)現(xiàn)簡(jiǎn)單登錄,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助2021-12-12Python實(shí)現(xiàn)將xml導(dǎo)入至excel
本文給大家講解的是使用Python的Testlink實(shí)現(xiàn)將實(shí)現(xiàn)將xml導(dǎo)入至excel表格中,方法非常的簡(jiǎn)單,另外附上其他小伙伴的方法,有需要的童鞋們可以參考下。2015-11-11Django如何利用uwsgi和nginx修改代碼自動(dòng)重啟
這篇文章主要介紹了Django如何利用uwsgi和nginx修改代碼自動(dòng)重啟問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-05-05python檢查序列seq是否含有aset中項(xiàng)的方法
這篇文章主要介紹了python檢查序列seq是否含有aset中項(xiàng)的方法,涉及Python針對(duì)序列的相關(guān)判斷技巧,需要的朋友可以參考下2015-06-06