Fixes the issue of handling NaN/None by using pandas Series in an optimized way.