Ryan
Ryan

Reputation: 10099

save to text from pandas dataframe

Im trying to save my dataframe which consists of 2 colums into a text file,I get this error of mismatch between array dtype,any suggestions on what i could do?

The error Image

Upvotes: 4

Views: 6780

Answers (1)

jezrael
jezrael

Reputation: 862431

Use DataFrame.to_csv:

df.to_csv('hopefully.txt', index=False, sep=' ', header=None)

For the file to be saved without a comma, use the sep=' '. To cut off the column title, header=None.

Upvotes: 7

Related Questions