python中的频率表

2024-05-19 12:51:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个连续值Tone。如何从数据帧创建频率表?在

dataframe.Tone = [-0.9, -0.8, -0.6, -0.3, -0.2, 0, 0.1, 0.2, 0.4, 0.7, 1.2, 1.3, 1.4]`

resultDF

^{pr2}$

Tags: 数据dataframe频率tonepr2resultdf
1条回答
网友
1楼 · 发布于 2024-05-19 12:51:17

IIUC使用cut

pd.cut(l,[-1,-0.6,-0.1,0.4,0.9,1.4]).value_counts()
(-1.0, -0.6]    3
(-0.6, -0.1]    2
(-0.1, 0.4]     4
(0.4, 0.9]      1
(0.9, 1.4]      3
dtype: int64

相关问题 更多 >