Source code for pyquickhelper.pandashelper.tblfunction

Various function to deal with pandas tables


[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 # pragma: no cover
[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) raise TypeError( # pragma: no cover "wrong type before calling numpy.isnan: {0}".format(type(s)))