pandas – Python Histogram ValueError: range parameter must be finite
pandas – Python Histogram ValueError: range parameter must be finite
Sounds like you have some NaNs
or inf
in your actual data. You can select only those values that are finite like this:
import numpy as np
df[np.isfinite(df[distance])]
So your plot can be obtained like:
plt.hist(df[np.isfinite(df[distance])].values)
Just to add to saculs answer, you can check if you have NaNs
or inf
on any of your columns using this:
For NaNs
:
df.isnull().sum()
For inf
:
df.max()
Hope it helps !
pandas – Python Histogram ValueError: range parameter must be finite
NaN cause the issue, i dont need to round it, just drop the NaN, then it works
plt.hist(df[distance].dropna().values)
plt.show()