The difference between NaN, None, and null in python and when to use each
In pure Python, you can assign a string a value or set it as empty '' or None.
Null is not an option… you can choose to set it as 'null' but there could be some issues down the road with this (because it doesn’t evaluate to null in Python).
Numpy’s np.nan value actually evaluates to the ‘float’ class here, and surprise surprise, it evaluates to Boolean value of True.
Test cases have been done for each of the Empty string, None, NaN, Zero values to see how python treats each of these values.
While summing a list of values (which include an np.nan value) doesn’t throw an exception… it returns nan! It does not exclude the nan value (which is probably what you want to do).
Adding (or multiplying) an np.nan value by anything results in, you guessed it, an nan value again.
np.nansum(my_list) will ignore np.nan values and treat them as 0’s in summation so there are no errors generated.
At this point, my brain is fried and I want it to absorb what I’ve learned.
For a production codebase, it is better to simply use python's None.