modin.pandas.Series.apply

Series.apply(func: Union[Callable, str, list[Union[Callable, str]], MutableMapping[Hashable, Union[Callable, str, list[Union[Callable, str]]]]], convert_dtype: bool = True, args: tuple[Any, ...] = (), **kwargs: Any)[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/modin/plugin/extensions/series_overrides.py#L980-L995)

Invoke function on values of Series.

Can be ufunc (a NumPy function that applies to the entire Series) or a Python function that only works on single values.

Parameters:
  • func (function) – Python function or NumPy ufunc to apply.

  • convert_dtype (bool, default None) – Try to find better dtype for elementwise function results. convert_dtype has been ignored with Snowflake execution engine.

  • args (tuple) – Positional arguments passed to func after the series value.

  • **kwargs – Additional keyword arguments passed to func.

Returns:

If func returns a Series object the result will be a DataFrame.

Return type:

Snowpark pandas Series or Snowpark pandas DataFrame

See also

Series.map : For applying more complex functions on a Series.

DataFrame.apply : Apply a function row-/column-wise.

DataFrame.applymap : Apply a function elementwise on a whole DataFrame.

Notes

1. When func has a type annotation for its return value, the result will be cast to the corresponding dtype. When no type annotation is provided, data will be converted to VARIANT type in Snowflake, and the result will have dtype=object. In this case, the return value must be JSON-serializable, which can be a valid input to json.dumps (e.g., dict and list objects are JSON-serializable, but bytes and datetime.datetime objects are not). The return type hint is used only when func is a series-to-scalar function.

2. Under the hood, we use Snowflake Vectorized Python UDFs. to implement apply() method. You can find type mappings from Snowflake SQL types to pandas dtypes here.

3. Snowflake supports two types of NULL values in variant data: JSON NULL and SQL NULL. When no type annotation is provided and Variant data is returned, Python None is translated to JSON NULL, and all other pandas missing values (np.nan, pd.NA, pd.NaT) are translated to SQL NULL.

  1. For working with 3rd-party-packages see DataFrame.apply.

Language: English