Data.apply

Data.apply(func, col=None, replace=True, header=None, **kargs)

Apply the given function to each row in the data set and adds to the data set.

Parameters:
  • func (callable) – The function to apply to each row of the data.

  • col (index) – The column in which to place the result of the function

Keyword Arguments:
  • replace (bool) – Either replace the existing column/complete data or create a new column or data file.

  • header (string or None) – The new column header(s) (defaults to the name of the function func

Note

If any extra keyword arguments are supplied then these are passed to the function directly. If you need to pass any arguments that overlap with the keyword arguments to :py:math:`AnalysisMixin.apply` then these can be supplied in a dictionary argument _extra.

The callable func should have a signature:

def func(row,**kargs):

and should return either a single float, in which case it will be used to repalce the specified column, or an array, in which case it is used to completely replace the row of data.

If the function returns a complete row of data, then the replace parameter will cause the return value to be a new datafile, leaving the original unchanged. The headers parameter can give the complete column headers for the new data file.

Returns:

(Stoner.Data) – The newly modified Data object.