Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

""" 

@file 

@brief Various function to deal with pandas tables 

""" 

 

 

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). 

""" 

if s is None: 

return True 

if isinstance(s, str): 

return len(s) == 0 

 

import numpy 

if numpy.isnan(s): 

return True 

return False 

 

 

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). 

""" 

if isinstance(s, float): 

import numpy 

return numpy.isnan(s) 

else: 

raise TypeError( 

"wrong type before calling numpy.isnan: {0}".format(type(s)))