captest.capdata.CapData.filter_custom
- CapData.filter_custom(func, *args, **kwargs)
Apply update_summary decorator to passed function.
- Parameters:
func (function) – Any function that takes a dataframe as the first argument and returns a dataframe. Many pandas dataframe methods meet this requirement, like pd.DataFrame.between_time.
*args – Additional positional arguments passed to func.
**kwds – Additional keyword arguments passed to func.
Examples
Example use of the pandas dropna method to remove rows with missing data.
>>> das.custom_filter(pd.DataFrame.dropna, axis=0, how='any') >>> summary = das.get_summary() >>> summary['pts_before_filter'][0] 1424 >>> summary['pts_removed'][0] 16
Example use of the pandas between_time method to remove time periods.
>>> das.reset_filter() >>> das.custom_filter(pd.DataFrame.between_time, '9:00', '13:00') >>> summary = das.get_summary() >>> summary['pts_before_filter'][0] 245 >>> summary['pts_removed'][0] 1195 >>> das.data_filtered.index[0].hour 9 >>> das.data_filtered.index[-1].hour 13