Issue with font family in JupyterLab

I’m having this issue with font family currently used in JupyterLab that displays pandas’ DataFrame.

At a glance, it seems that you have three string values and each has a different length, but they actually all have exact six characters.
image

I wonder if the design team at JupyterLab also finds this to be an issue and if there is any workaround or fix for this.

I think that’s controlled by Pandas not Jupyter. Pandas has a lot of options for customising the display: Options and settings — pandas 1.3.4 documentation
but after a quick glance it doesn’t look like there are any font options.

2 Likes

I think it might be a Jupyter/HTML issue:

image

The content font is system-determined, and eventually falls back to sans-serif… but this is almost always going to be variable width, because most (western) scripts look better that way for prose.

A simple, cross-platform, ugly way to force fixed-width would be:

%%html
<stryle>
.dataframe th {font-family: monospace;} 
</style>

…Or via the pandas API.

Some other alternatives to “dumb” monospace:

  • explore what fonts you have locally
    • but then risk not having a portable option.
  • use a google fonts option
3 Likes

@bollwyvl I really hope you guys could log this somewhere and really wish there could be a solution for this.