gpt4 book ai didi

data-cleaning - OpenRefine - 将多个列值合并到新列应该(?)工作

转载 作者:行者123 更新时间:2023-12-04 01:34:59 27 4
gpt4 key购买 nike

我的数据包括多个列——就我的目的而言——是相同的。在这些地方,我需要将多个选定列中的值组合成一个列。例如,将列名称 1、名称 2 和名称 3 合并为一个列名称。

遵循指导 here ,我正在尝试创建一个新列,其中包含来自多个列的值,如下图所示:

Column options

Add column based on column X dialog box

相信我的 GREL 在这里应该结合 dc.contributor.author 中的值(简单的 value 因为这是从中的列我选择了编辑列> 根据此列添加列), dc.contributor.authorEN_us (cells["dc.contributor.authorEN_us"].value)、dc.contributor.author1(cells["dc.contributor.author1"].value)和 dc.contributor.authoren_US(cells["dc.contributor.authoren_US "].value).

但是,我的新列不包含来自这些第二、第三或第四列的值,即使我知道这些值存在。

我的 GREL 语法是否有错误?我应该使用不同的方法来合并列吗?

在此先感谢您的帮助。

最佳答案

恐怕您一直在查看的教程既过时又不完整。问题是您在某些列中有值 null。在 OpenRefine 中,连接(即通过 + 连接两个字符串)returns null if one of the values is null .

所以:

"Hello"+ ""+ "World" 给出“Hello World”。

但是

"Hello"+ null + ""+ "World" 返回 null

已经有endless discussions关于这个问题。直到最近,我还建议您使用:

或者:

coalesce(value,cells['dc.contributor.author1'].value, cells['dc.contributor.authorEN_us'].value, cells['dc.contributor.authoren_US'].value)

(Openrefine 3 中引入的 coalesce function 返回系列中的第一个非空值)

或:

value.toString() + cells['dc.contributor.authorEN_us'].value.toString() + cells['dc.contributor.authoren_US'].value.toString()

(将null转为空字符串'')

但在未来的 OpenRefine 3.3(现在处于测试阶段)中,感谢@mathieu-saby,OpenRefine 将有一个菜单,让您可以轻松地合并列。你只需要 update your version . :)

Screenshot of the Column Menu, with the submenu "Edit column" opened and the entry "Join columns..." highlighted.

关于data-cleaning - OpenRefine - 将多个列值合并到新列应该(?)工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59865732/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com