A RetroSearch Logo

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

Search Query:

Showing content from https://pandas.pydata.org/pandas-docs/stable/reference/api/../api/pandas.Index.map.html below:

pandas.Index.map — pandas 2.3.1 documentation

pandas.Index.map#
Index.map(mapper, na_action=None)[source]#

Map values using an input mapping or function.

Parameters:
mapperfunction, dict, or Series

Mapping correspondence.

na_action{None, ‘ignore’}

If ‘ignore’, propagate NA values, without passing them to the mapping correspondence.

Returns:
Union[Index, MultiIndex]

The output of the mapping function applied to the index. If the function returns a tuple with more than one element a MultiIndex will be returned.

Examples

>>> idx = pd.Index([1, 2, 3])
>>> idx.map({1: 'a', 2: 'b', 3: 'c'})
Index(['a', 'b', 'c'], dtype='object')

Using map with a function:

>>> idx = pd.Index([1, 2, 3])
>>> idx.map('I am a {}'.format)
Index(['I am a 1', 'I am a 2', 'I am a 3'], dtype='object')
>>> idx = pd.Index(['a', 'b', 'c'])
>>> idx.map(lambda x: x.upper())
Index(['A', 'B', 'C'], dtype='object')

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