Python Error1: ValueError: range parameter must be finite.

C:\Program Files\Anaconda2\lib\site-packages\astropy\visualization\hist.pyc in hist(x, bins, ax, **kwargs)
     54     arglist = list(signature(np.histogram).parameters.keys())[1:]
     55     np_hist_kwds = dict((key, kwargs[key]) for key in arglist if key in kwargs)
---> 56     hist, bins = histogram(x, bins, **np_hist_kwds)
     57 
     58     if ax is None:

C:\Program Files\Anaconda2\lib\site-packages\astropy\stats\histogram.pyc in histogram(a, bins, range, weights, **kwargs)
 82             bins = bayesian_blocks(a)
 83         elif bins == 'knuth':
---> 84 da, bins = knuth_bin_width(a, True)  85 elif bins == 'scott':  86 da, bins = scott_bin_width(a, True) C:\Program Files\Anaconda2\lib\site-packages\astropy\stats\histogram.pyc in knuth_bin_width(data, return_bins, quiet)  272 knuthF = _KnuthF(data)  273 dx0, bins0 = freedman_bin_width(data, True) --> 274 M = optimize.fmin(knuthF, len(bins0), disp=not quiet)[0]  275 bins = knuthF.bins(M)  276 dx = bins[1] - bins[0] C:\Program Files\Anaconda2\lib\site-packages\scipy\optimize\optimize.pyc in fmin(func, x0, args, xtol, ftol, maxiter, maxfun, full_output, disp, retall, callback, initial_simplex)  391 'initial_simplex': initial_simplex}  392  --> 393 res = _minimize_neldermead(func, x0, args, callback=callback, **opts)  394 if full_output:  395 retlist = res['x'], res['fun'], res['nit'], res['nfev'], res['status'] C:\Program Files\Anaconda2\lib\site-packages\scipy\optimize\optimize.pyc in _minimize_neldermead(func, x0, args, callback, maxiter, maxfev, disp, return_all, initial_simplex, xatol, fatol, **unknown_options)  515   516 for k in range(N + 1): --> 517 fsim[k] = func(sim[k])  518   519 ind = numpy.argsort(fsim) C:\Program Files\Anaconda2\lib\site-packages\scipy\optimize\optimize.pyc in function_wrapper(*wrapper_args)  290 def function_wrapper(*wrapper_args):  291 ncalls[0] += 1 --> 292 return function(*(wrapper_args + args))  293   294 return ncalls, function_wrapper C:\Program Files\Anaconda2\lib\site-packages\astropy\stats\histogram.pyc in __call__(self, M)  327   328 def __call__(self, M): --> 329 return self.eval(M)  330   331 def eval(self, M): C:\Program Files\Anaconda2\lib\site-packages\astropy\stats\histogram.pyc in eval(self, M)  349   350 bins = self.bins(M) --> 351 nk, bins = np.histogram(self.data, bins)  352   353 return -(self.n * np.log(M) + C:\Program Files\Anaconda2\lib\site-packages\numpy\lib\function_base.pyc in histogram(a, bins, range, normed, weights, density)  503 if not np.all(np.isfinite([mn, mx])):  504 raise ValueError( --> 505 'range parameter must be finite.')  506 if mn == mx:  507 mn -= 0.5 ValueError: range parameter must be finite.
 
 
 
当在使用hist() 或者histogram() 遇到上述错误,多数是数据中存在NaN,使用fillna()等转化NaN 为其他numeric即可

你可能感兴趣的:(Python,Error)