2

I have a dataframe where one of the columns contains strings. But they have some tab formatting for each of them. Below is a snippet of how it looks like

formatted_line_items[1:3]
Out[393]: ['\t<string1>', '\t\t<string2>']

However when I write the dataframe using to_csv the formatting is lost. How can I write this to a csv file or excel file and still retain the formatting?

EDIT: I got to know that csv doesn't retain formatting so I used the pandas to_excel function but still no luck with the formatting.

1 Answer 1

1

Just found XlsxWriter has a set_indent function where we can specify the indentation.

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

Comments

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.