python - Why does np.percentile return NaN for high percentiles? -


this code:

print len(my_series) print np.percentile(my_series, 98) print np.percentile(my_series, 99) 

gives:

14221  # series length 1644.2  # 98th percentile nan  # 99th percentile? 

why 98 work fine 99 gives nan?

np.percentile treats nan's high/infinite numbers. high percentiles in range end nan. in case, between 1 , 2 percent of data nan's (98th percentile return number (which not 98th percentile of valid values) , 99th return nan).

to calculate percentile without nan's, can use np.nanpercentile()

so:

print np.nanpercentile(my_series, 98) print np.nanpercentile(my_series, 99) 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -