hyat
hyat

Reputation: 1057

How to write a data to a text file in python?

I am a knew to python and I started my first codes in Python but I can not write my data to a text file. Can anyone help me in writing my data here to a text file:

I am using Python 3.4

 In [66]:data
 Out[66]: 
                                  var1         var2
 20:22:49.999985        0.2160       0.1720

Upvotes: 0

Views: 1822

Answers (2)

Shreevardhan
Shreevardhan

Reputation: 12641

You can

file = open('filename', 'w');
file.write(data.to_string());    // if data is a pandas.DataFrame object
file.close();

Upvotes: 1

LennyB
LennyB

Reputation: 359

open('out.txt', 'w').write(data)

Upvotes: 1

Related Questions