Python, Pandas : write content of DataFrame into text File

前端 未结 7 1936
再見小時候
再見小時候 2020-11-27 11:49

I have pandas DataFrame like this

        X    Y  Z    Value 
0      18   55  1      70   
1      18   55  2      67 
2      18   57  2      75     
3      1         


        
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 12:22

    Late to the party: Try this>

    base_filename = 'Values.txt'
    with open(os.path.join(WorkingFolder, base_filename),'w') as outfile:
        df.to_string(outfile)
    #Neatly allocate all columns and rows to a .txt file
    

提交回复
热议问题