Search code examples
pythonpandasdataframepandas-styles

how to apply Pandas.set_option (Python) to pandas.style objects


I have noticed that when we set some options for pandas DataFrames such as pandas.DataFrame('max_rows',10) it works perfectly for DataFrame objects.

However, it has no effect on Style objects.

Check the following code :

import pandas as pd
import numpy as np

data= np.zeros((10,20))

pd.set_option('max_rows',4)
pd.set_option('max_columns',10)
df=pd.DataFrame(data)

display(df) 
display(df.style)

Which will result in : Result

I do not know how to set the properties for Styler object.


Solution

  • Styler is developing its own options. The current version 1.3.0 of pandas has not got many. Perhaps only the styler.render.max_elements.

    Some recent pull requests to the github repo are adding these features but they will be Stylers own version.