I want to discretize a pandas continuous column. For discretization, I'm using Freedman-Diaconis rule which computes the optimal number of bins which will be given input to KBinsDiscretizer. Freedman-Diaconis' rule states that,
$$ \text{bin width}, h=2\frac{\operatorname{IQR}(x)}{n^{1/3}} $$ $$ \text{number of bins}, k = \frac{range(x)}{h} $$
The column has $32561$ values. After sorting, the first $29849$ elements are $0$. So in turn the $IQR(x) = 0$. So, a divide by zero occurs when calculating the number of bins. What can I do here?
