'How to make sure that columns and rows will be printed as straigth lines using pandas?
We can set this options to align the headers of the columns to 'center':
pd.set_option('display.colheader_justify', 'center')
How can we justify the data of the columns, when I print the data frame to a txt file I do not get the whole data in straight columns and rows.
Solution 1:[1]
Use to_string:
with open('output.txt', 'w') as fp:
print(df.to_string(), file=fp)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Corralien |
