4

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

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks,that works but i was hoping to save the file without the comma,in this file there is a comma in between, i need just a space in between,what do i do get that?
@Abien Fred Agarap - Thank you.
Thanks a million man!! once i get 15 rep points ,ill make sure to come back and accept.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.