Skip to content

bodo.pandas.BodoSeries.map

BodoSeries.map(arg, na_action=None) -> BodoSeries
Map values of a BodoSeries according to a mapping.

Note

Calling BodoSeries.map will immediately execute a plan to generate a small sample of the BodoSeries and then call pandas.Series.map on the sample to infer output types before proceeding with lazy evaluation.

Parameters

arg : function, collections.abc.Mapping subclass or Series: Mapping correspondence.

na_actions : {None, ‘ignore’}, default None: If 'ignore' then NaN values will be propagated without passing them to the mapping correspondence.

Returns

BodoSeries

Example

import bodo.pandas as bodo_pd
import pandas as pd

df = pd.DataFrame(
    {
        "A": pd.array([1, 2, 3, 7] * 3, "Int64"),
        "B": ["A1", "B1", "C1", "Abc"] * 3,
        "C": pd.array([4, 5, 6, -1] * 3, "Int64"),
    }
)

bdf = bodo_pd.from_pandas(df)
bodo_ser = bdf.A.map(lambda x: x ** 2)
print(type(bodo_ser))
print(bodo_ser)

Output:

<class 'bodo.pandas.series.BodoSeries'>
0      1
1      4
2      9
3     49
4      1
5      4
6      9
7     49
8      1
9      4
10     9
11    49
Name: A, dtype: int64[pyarrow]