简体   繁体   English

如何从numpy.histogram获取实数?

[英]How to get real numbers from numpy.histogram?

I have a collection of data that needs to be presented as a histogram. 我有一组数据需要以直方图的形式呈现。 When I use numpy.histogram, the values that would go along the x-axis are using Eulers number, which is counterproductive. 当我使用numpy.histogram时,沿x轴的值将使用Eulers数字,这会适得其反。 How do I convert these numbers back to a normal number? 如何将这些数字转换回普通数字? The numbers are large, ranging into the tens of millions. 数字很​​大,有几千万。

I haven't tried researching how Eulers number is used to try and write my own code to reverse it, but I haven't found anything

from bokeh.plotting import output_file, figure, show
import numpy as np
from excelParser import parseExcelFile #custom method for parsing excel data
from math import exp

rawData = parseExcelFile("histogram-data.xlsx", False) #gets the data
filteredData = []

#filters the data
for key in rawData:
       filteredData.append(rawData[key]['total_revenue'] / 1000000)

histData = np.histogram(filteredData, bins='scott') #calculates histogram data

print(histData[1])

Result: 结果:

[1.00000000e-03 2.36480474e+00 4.72860948e+00 7.09241422e+00
 9.45621896e+00 1.18200237e+01 1.41838284e+01 1.65476332e+01
 1.89114379e+01 2.12752427e+01 2.36390474e+01 2.60028521e+01
 2.83666569e+01 3.07304616e+01 3.30942663e+01 3.54580711e+01
 3.78218758e+01 4.01856806e+01 4.25494853e+01 4.49132900e+01
 4.72770948e+01 4.96408995e+01 5.20047043e+01 5.43685090e+01]

答案中,在打印之前包括np.set_printoptions(precision=3, suppress=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM