Now, I'm aware that the new version of pandas has a special data type extension 'Int64' that allows missing values to coexist with integers in the same column, this topic explains as much. However, I'd like to have an integer column that also allows infinity values. But when I'm trying to add float('inf')
into the column that has a 'Int64' type, I get an error: "cannot safely cast non-equivalent float64 to int64".
The reason why I want infinity values in my column is that I have a column of integer distances, and while some of these distances are unknown, it is known that such distances are over, say, 3000 meters. And when I calculate the median of this column, it makes a difference. For example, the median of an array [1, 5, 10, 20, 50, nan, nan, nan] is 10, because NaN values are ignored. But the median of an array [1, 5, 10, 20, 50, inf, inf, nan] is 20, because inf values are considered larger than 50.
Is there any way to make integers compatible with 'inf' values? Or do I have to make do with float?