MulSeries.call#

MulSeries.call(func, *args, **kwargs)#

Apply a function to the values series and returns the result as a scalar or a MulSeries with the index dataframe properly arranged.

Parameters:#

funcfunction or str

A function applied to the values series of the MulSeries. The function should return a scalar, or a pandas Series.

  • If a Series is returned, it must have the same index as the primary index (order can be different if there are no duplicate values in the primary index).

  • If func is a string, it must be a valid method name of pandas.Series. The method should saftisfy the same requirement as above.

*argspositional arguments to the function

The MulSeries is the 1st positional argument to the function. *args are from the 2nd positional argument onwards.

**kwargskeyword arguments to the function

keyword arguments to the function.

Returns#

scalar or MulSeries

If the return value is a MulSeries, it should have the same index dataframe as the caller.

Examples#

>>> import pandas as pd
>>> import muldataframe as md
>>> import numpy as np
>>> index = pd.DataFrame([[1,2],[3,6],[5,6]],
             index=['a','b','b'],
             columns=['x','y'])
>>> name = pd.Series([5,7],
                index=['f','g'],
                name='c')
>>> ms = MulSeries([1,8,9],index=index,name=name)
>>> ms.call(np.power,2)
(3,)      g  7
          f  5
             c
-------  ------
   x  y      c
a  1  2  a   1
b  3  6  b  64
b  5  6  b  81