Source code for pyquickhelper.pandashelper.tblfunction

"""
Various function to deal with pandas tables


:githublink:`%|py|5`
"""


[docs]def isempty(s): """ checks that a string is empty, returns also True if s is ``NaN`` :param s: ``str`` or ``numpy.NaN`` :return: boolean The function imports :epkg:`numpy` (delayed import). :githublink:`%|py|15` """ if s is None: return True if isinstance(s, str): return len(s) == 0 import numpy if numpy.isnan(s): return True return False
[docs]def isnan(s): """ calls :epkg:`numpy:isnan` but checks it is a float first :param s: object :return: boolean @raise TypeError if ``s`` is not a ``float`` The function imports :epkg:`numpy` (delayed import). :githublink:`%|py|37` """ if isinstance(s, float): import numpy return numpy.isnan(s) else: raise TypeError( "wrong type before calling numpy.isnan: {0}".format(type(s)))