Created
November 15, 2017 07:54
-
-
Save yassineAlouini/3bcbb2dda8ac4495e872d1a091674f35 to your computer and use it in GitHub Desktop.
Log shape and dtypes of a DataFrame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
from logs import logger | |
# Two decorator to log the shape and dtypes of a DataFrame | |
# Inspired from here: https://tomaugspurger.github.io/method-chaining | |
def log_shape(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
result = func(*args, **kwargs) | |
logger.debug("%s,%s" % (func.__name__, result.shape)) | |
return result | |
return wrapper | |
def log_dtypes(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
result = func(*args, **kwargs) | |
logger.debug("%s,%s" % (func.__name__, result.dtypes)) | |
return result | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment