clarite.modify.transform

clarite.modify.transform(data:pandas.core.frame.DataFrame, variable:str, transform:str, new_name:Union[str, NoneType]=None)

Apply a transformation function to a variable

Parameters
data: pd.DataFrame or pd.Series

Data to be processed

variable: str

Variable to apply the transformation to

transform: str

Name of the transformation (Python function or NumPy ufunc to apply)

new_name: str or None

Name of the transformed variable

Returns
data: pd.DataFrame

DataFrame with a new transformed variable replacing the original

Examples

>>> import clarite
>>> df = clarite.modify.transform(df, 'BMXBMI', 'log', 'logBMI')
================================================================================
Running transform
--------------------------------------------------------------------------------
Transformed 'BMXBMI' using 'log' (saved as 'logBMI').