I am using pandas in a jupyter notebook and I would like to export my notebook in a pdf document using quarto. Everything work except the alignment of numbers in the table. If you have positive and negative numbers and the numbers are left aligned they are difficult to read because the dot is not aligned along the column.
Here is the python code that produce the table, it comes from pandas docs:
import pandas as pd
import numpy as np
df = pd.DataFrame(
np.random.randn(10, 2) * 5,
index=pd.date_range(start="2021-01-01", periods=10),
columns=["Tokyo", "Beijing"])
# display the table with a style
df.style.format(precision=3).format_index(lambda v: v.strftime("%A"))
The result in the notebook is ok and looks like:
But the output in the pdf is the following, the column are left aligned, which is not what I want:
I also tried to use a format spec like "{:>10.3f}"
in order to force to be right aligned but without success.