Using pandas' where() function
pandas’ where() function doesn’t replace nan values in float64 columns by default. Instead, it retains the original nan values unless explicitly instructed to replace them.
Coupled with the fact that data read in from lots of SQL operations such as min() and max() result in null values (which become nan in pandas and are treated as float64 columns), this means that where() may not behave as expected if it’s being used to fill/select/exclude those nan values.
This post is licensed under CC BY 4.0 by the author.