dolphindb中有进行数据分箱的函数吗

请问dolphindb中有进行数据分箱的函数吗,类似pandas.cut这种

请先 登录 后评论

1 个回答

wfHuang

DolphinDB中有bucket函数,函数的具体语法和参数可以参考https://docs.dolphindb.cn/zh/help/FunctionsandCommands/FunctionReferences/b/bucket.html?highlight=bucket

下面是一个DolphinDB和pandas进行数据分箱操作的对比示例:

DolphinDB中的示例:

bucket(9 23 54 36 46 12, 12:54, 2);
[,0,,1,1,0]
bucket(9 23 54 36 46 12, 12:54, 2, 1); [0,1,3,2,2,1]

pandas中的示例:

import pandas as pd

# 创建一维数组
data = [9, 23, 54, 36, 46, 12]

# 定义箱体边界
bins = [12, 33, 54]

# 使用pandas.cut进行数据分箱
bins_result = pd.cut(data, bins)

# 打印结果
print(bins_result)


请先 登录 后评论
  • 1 关注
  • 0 收藏,272 浏览
  • hmWei 提出于 2024-01-12 15:33

相似问题