pandahandler.frames.decorators.framesize

Function decorators for functions that accept a data frame and return a data frame.

Functions

log_rowcount_change(→ Any)

Log the change in the number of rows of a data frame processed by func.

Module Contents

pandahandler.frames.decorators.framesize.log_rowcount_change(func: pandahandler.frames.constants.DataframeToDataframe | None = None, *, logger: logging.Logger | None = None, level: int = logging.INFO, stacklevel: int = 2, allow_empty_input: bool = True, allow_empty_output: bool = True, describe_func: Callable[Ellipsis, str] = _get_function_name) Any[source]

Log the change in the number of rows of a data frame processed by func.

This decorator can be used with or without arguments:

@log_rowcount_change
def my_func(df): ...

@log_rowcount_change(level=logging.DEBUG)
def my_func(df): ...
Parameters:
  • func – The function to decorate (when used without parentheses).

  • logger – The logger to use. If None, the logger for the module calling the decorated function is used.

  • level – The logging level to use, defaulting to INFO. Note that this sets the logging level for your decorator, NOT the logger. For example, if you set level=logging.DEBUG, the decorator will log only when the logger is set to DEBUG or lower.

  • stacklevel – Passed into the logger.log call: 1: The log message shows the line number of the logging call inside the decorator itself. 2 (default): the log message shows the line number of the call to the decorated function.

  • allow_empty_input – If False, raise an exception if the input data frame is empty.

  • allow_empty_output – If False, raise an exception if the output data frame is empty.

  • describe_func – A function that takes the decorated function and its arguments and returns a string description of the function. The default implementation returns the function’s name.

Raises:
  • ValueError – If the input data frame is empty and allow_empty_input is False.

  • RuntimeError – If the output data frame is empty and allow_empty_output is False.