Skip to content Skip to sidebar Skip to footer

Pd.qcut With Values That Are Inf (infinity) Valueerror: Bin Edges Must Be Unique:

I have a data set that is a ratio of 2 float type numbers. Some values have inf for infinity (divide by zero) situation. How do I work with pd.qcut/pd.cut with inf values? My dat

Solution 1:

you could replace the np.inf with np.nan then dropna

q = pd.qcut(df.ratio.replace(np.inf, np.nan).dropna(), 10)

Post a Comment for "Pd.qcut With Values That Are Inf (infinity) Valueerror: Bin Edges Must Be Unique:"