bigframes.geopandas.GeoSeries.map#

GeoSeries.map(arg: Mapping | Series | Callable, na_action: str | None = None, *, verify_integrity: bool = False) Series#

Map values of Series according to an input mapping or function.

Used for substituting each value in a Series with another value, that may be derived from a remote function, dict, or a Series.

If arg is a remote function, the overhead for remote functions applies. If mapping with a dict, fully deferred computation is possible. If mapping with a Series, fully deferred computation is only possible if verify_integrity=False.

Note

Bigframes does not yet support dict subclasses that define __missing__ (i.e. provide a method for default values). These are treated the same as dict.

Examples:

>>> s = bpd.Series(['cat', 'dog', pd.NA, 'rabbit'])
>>> s
0       cat
1       dog
2      <NA>
3    rabbit
dtype: string

map can accepts a dict. Values that are not found in the dict are converted to NA:

>>> s.map({'cat': 'kitten', 'dog': 'puppy'})
0    kitten
1     puppy
2      <NA>
3      <NA>
dtype: string

It also accepts a remote function:

>>> @bpd.remote_function(cloud_function_service_account="default")
... def my_mapper(val: str) -> str:
...     vowels = ["a", "e", "i", "o", "u"]
...     if val:
...         return "".join([
...             ch.upper() if ch in vowels else ch for ch in val
...         ])
...     return "N/A"
>>> s.map(my_mapper)
0       cAt
1       dOg
2       N/A
3    rAbbIt
dtype: string
Parameters:
  • arg (function, Mapping, Series) – remote function, collections.abc.Mapping subclass or Series Mapping correspondence.

  • na_action – (str, default None) Only None is currently supported, indicating that arg may map <NA> values to scalars. <NA> values won’t be ignored. Passing ‘ignore’ will raise NotImplementedException.

  • verify_integrity – (bool, default False) Only applies when arg is a Series. If True, throw if the Series index contains duplicate entries (this matches pandas behavior). If False, skip the expensive computation, and any duplicate index entries will produce duplicate rows in the result for each index entry.

Returns:

Same index as caller.

Return type:

bigframes.pandas.Series