众数

x=[1 ,1 ,4, 4, 5 ,7, 7, 7, 9]

res=pd.cut(x,bins=4,include_lowest=True)
#[(0.991, 3.0], (0.991, 3.0], (3.0, 5.0], (3.0, 5.0], (3.0, 5.0], (5.0, 7.0], (5.0, 7.0], (5.0, 7.0], (7.0, 9.0]]

ret=st.mode(res)
#odeResult(mode=array([Interval(3.0, 5.0, closed='right')], dtype=object), count=array([3]))

originalChargeMode = ((ret[0][0]).left + (ret[0][0]).right) / 2
#4

posted on 2018-09-17 10:55  happygril3  阅读(79)  评论(0编辑  收藏  举报

导航