Here is a sneaky one: when using pandas.read_sql() to retrieve the results of a query straight into a DataFrame, NULL values can end up as None in your DataFrame. This will most likely screw up some of your downstream calculations.

Normally NULL values are converted to numpy.nan in pandas.read_sql(). Except when all the values are NULL in a returned column, because then these will be coerced to None. Surprise, surprise!

According to this Github issue, the problem is still there (as of pandas 0.24, at least), and the only workaround is to replace None with proper numpy.nan values in the dataframe itself, like pd.read_sql('...').replace([None], np.nan).

I spent more than an hour figuring this out…