This has been stumping me for a while and I feel like there has to be a solution since printing a dataframe always aligns the columns headers with their respective values.
example:
df = pd.DataFrame({'First column name': [1234, 2345, 3456], 'Second column name': [5432,4321,6543], 'Third column name': [1236,3457,3568]})
df_string = df.to_string(justify='left', col_space='30')
now when you print df_string, you get the desired formatting:
but when I take the string and view it (in this case, I'm passing the string to a PyQt widget that displays text), this is the output:
(this is how the string appears on my console):
Any help is greatly appreciated.