# dask.dataframe.Series.apply

#### Series.apply(function, \*args, meta=<no_default>, axis=0, \*\*kwargs)

Parallel version of pandas.Series.apply

* **Parameters:**
  **func**
  : Function to apply

  **meta**
  : An empty `pd.DataFrame` or `pd.Series` that matches the dtypes
    and column names of the output. This metadata is necessary for
    many algorithms in dask dataframe to work.  For ease of use, some
    alternative inputs are also available. Instead of a `DataFrame`,
    a `dict` of `{name: dtype}` or iterable of `(name, dtype)`
    can be provided (note that the order of the names should match the
    order of the columns). Instead of a series, a tuple of `(name,
    dtype)` can be used. If not provided, dask will try to infer the
    metadata. This may lead to unexpected results, so providing
    `meta` is recommended. For more information, see
    `dask.dataframe.utils.make_meta`.

  **args**
  : Positional arguments to pass to function in addition to the value.

  **Additional keyword arguments will be passed as keywords to the function.**
* **Returns:**
  **applied**

#### SEE ALSO
[`Series.map_partitions`](dask.dataframe.Series.map_partitions.html.md#dask.dataframe.Series.map_partitions)

### Examples

```pycon
>>> import dask.dataframe as dd
>>> s = pd.Series(range(5), name='x')
>>> ds = dd.from_pandas(s, npartitions=2)
```

Apply a function elementwise across the Series, passing in extra
arguments in `args` and `kwargs`:

```pycon
>>> def myadd(x, a, b=1):
...     return x + a + b
>>> res = ds.apply(myadd, args=(2,), b=1.5)
```

By default, dask tries to infer the output metadata by running your
provided function on some fake data. This works well in many cases, but
can sometimes be expensive, or even fail. To avoid this, you can
manually specify the output metadata with the `meta` keyword. This
can be specified in many forms, for more information see
`dask.dataframe.utils.make_meta`.

Here we specify the output is a Series with name `'x'`, and dtype
`float64`:

```pycon
>>> res = ds.apply(myadd, args=(2,), b=1.5, meta=('x', 'f8'))
```

In the case where the metadata doesn’t change, you can also pass in
the object itself directly:

```pycon
>>> res = ds.apply(lambda x: x + 1, meta=ds)
```

<!-- !! processed by numpydoc !! -->
