Styler.format(self, formatter, subset=None)
[source]
Format the text display value of cells.
New in version 0.18.0.
Parameters: |
|
---|---|
Returns: |
|
formatter
is either an a
or a dict {column name: a}
where a
is one of
a.format(x)
The default display value for numeric values is the “general” (g
) format with pd.options.display.precision
precision.
>>> df = pd.DataFrame(np.random.randn(4, 2), columns=['a', 'b']) >>> df.style.format("{:.2%}") >>> df['c'] = ['a', 'b', 'c', 'd'] >>> df.style.format({'c': str.upper})
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.25.0/reference/api/pandas.io.formats.style.Styler.format.html