Coverage for pyquickhelper/pandashelper/tblfunction.py: 100%
12 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-03 02:21 +0200
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-03 02:21 +0200
1"""
2@file
3@brief Various function to deal with pandas tables
4"""
7def isempty(s):
8 """
9 checks that a string is empty, returns also True if s is ``NaN``
11 @param s ``str`` or ``numpy.NaN``
12 @return boolean
14 The function imports :epkg:`numpy` (delayed import).
15 """
16 if s is None:
17 return True
18 if isinstance(s, str):
19 return len(s) == 0
21 import numpy
22 if numpy.isnan(s):
23 return True
24 return False # pragma: no cover
27def isnan(s):
28 """
29 calls :epkg:`numpy:isnan` but checks it is a float first
31 @param s object
32 @return boolean
34 @raise TypeError if ``s`` is not a ``float``
36 The function imports :epkg:`numpy` (delayed import).
37 """
38 if isinstance(s, float):
39 import numpy
40 return numpy.isnan(s)
41 raise TypeError( # pragma: no cover
42 f"wrong type before calling numpy.isnan: {type(s)}")