A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/docs/reference/api/pandas.api.extensions.ExtensionArray._formatter.html below:

pandas.api.extensions.ExtensionArray._formatter — pandas 2.3.1 documentation

pandas.api.extensions.ExtensionArray._formatter#
ExtensionArray._formatter(boxed=False)[source]#

Formatting function for scalar values.

This is used in the default ‘__repr__’. The returned formatting function receives instances of your scalar type.

Parameters:
boxedbool, default False

An indicated for whether or not your array is being printed within a Series, DataFrame, or Index (True), or just by itself (False). This may be useful if you want scalar values to appear differently within a Series versus on its own (e.g. quoted or not).

Returns:
Callable[[Any], str]

A callable that gets instances of the scalar type and returns a string. By default, repr() is used when boxed=False and str() is used when boxed=True.

Examples

>>> class MyExtensionArray(pd.arrays.NumpyExtensionArray):
...     def _formatter(self, boxed=False):
...         return lambda x: '*' + str(x) + '*' if boxed else repr(x) + '*'
>>> MyExtensionArray(np.array([1, 2, 3, 4]))
<MyExtensionArray>
[1*, 2*, 3*, 4*]
Length: 4, dtype: int64

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4