Search code examples
pandasdataframedata-sciencedata-analysis

pandas.qcut returning NaN values


enter image description here

I want to make a new column from "TotalPrice" with qcut function but some values returns as NaN. I don't know why?

I tried to change the data type of the column. But nothing has changed.


Solution

  • Edit: you are doing a cqut on df rather than rfm dataframe. Ensure that this is what you expect to be doing

    Because you did not provide some data to build a minimal reproducible example, I would guess that there's not enough data or too many repeated values. Then, the underlying quartile function may fail to find the edge of the quantile and returns NaN

    (this did not make any sense because "M" buckets did not make sense with "TotalPrice")