Elementwise operation for Dask dataframes Parameters ---------- op: callable Function to apply across input dataframes *args: DataFrames, Series, Scalars, Arrays, The arguments of the operation meta: pd.DataFrame, pd.Series (optional) Valid metadata for t
(op, *args, meta=no_default, out=None, transform_divisions=True, **kwargs)
| 6424 | |
| 6425 | |
| 6426 | def elemwise(op, *args, meta=no_default, out=None, transform_divisions=True, **kwargs): |
| 6427 | """Elementwise operation for Dask dataframes |
| 6428 | |
| 6429 | Parameters |
| 6430 | ---------- |
| 6431 | op: callable |
| 6432 | Function to apply across input dataframes |
| 6433 | *args: DataFrames, Series, Scalars, Arrays, |
| 6434 | The arguments of the operation |
| 6435 | meta: pd.DataFrame, pd.Series (optional) |
| 6436 | Valid metadata for the operation. Will evaluate on a small piece of |
| 6437 | data if not provided. |
| 6438 | transform_divisions: boolean |
| 6439 | If the input is a ``dask.dataframe.Index`` we normally will also apply |
| 6440 | the function onto the divisions and apply those transformed divisions |
| 6441 | to the output. You can pass ``transform_divisions=False`` to override |
| 6442 | this behavior |
| 6443 | out : ``dask.array`` or ``None`` |
| 6444 | If out is a dask.DataFrame, dask.Series or dask.Scalar then |
| 6445 | this overwrites the contents of it with the result |
| 6446 | **kwargs: scalars |
| 6447 | |
| 6448 | Examples |
| 6449 | -------- |
| 6450 | >>> elemwise(operator.add, df.x, df.y) # doctest: +SKIP |
| 6451 | """ |
| 6452 | |
| 6453 | args = _maybe_from_pandas(args) |
| 6454 | dfs = [df for df in args if isinstance(df, FrameBase)] |
| 6455 | if len(dfs) <= 1 or expr.are_co_aligned(*dfs): |
| 6456 | result = new_collection( |
| 6457 | expr.UFuncElemwise(dfs[0], op, meta, transform_divisions, kwargs, *args) |
| 6458 | ) |
| 6459 | else: |
| 6460 | result = new_collection(expr.UFuncAlign(dfs[0], op, meta, kwargs, *args)) |
| 6461 | return handle_out(out, result) |
| 6462 | |
| 6463 | |
| 6464 | def handle_out(out, result): |
no test coverage detected