Skip to content
Advertisement

Is it possible to display pandas styles in the IPython console?

Is it possible to display pandas styles in an iPython console? The following code in a Jupyter notebook

JavaScript

correctly produces

enter image description here

In the console I only get

JavaScript

Is it possible to achieve a similar result here, or is the style engine dependent on an html frontend?

Thanks in advance for any help.

Advertisement

Answer

I believe that the styler really requires an html frontend, like jupyter, even if it only formats numbers (and not fonts or colors).

See e.g. here Using Pandas Styler.

In order to convert a column to a specific format, one should use the .map method:

JavaScript

The drawback is, that df[‘C’] is not a number anymore, so you cannot properly sort the dataframe anymore.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement