问题描述
时可以转动,在星火斯卡拉非数字值的表?我审查,以下两个堆栈的问题。
继中的案例当列表的问题,我可以将我的数据,使每个数据类型是列,但对于每个实体数据类型组合一排中的步骤。
ID标签值
1美国富
1英国酒吧
1 CA巴兹
2 US呼
2 UK哈
2 CA华ID美国英国CA
美孚1
1条
1巴兹
2呼
2哈
3华
有没有第一个非空功能,可以折叠的多行每个实体逼到一个?
ID美国英国CA
1富酒吧巴兹
2呼哈华
您可以考虑在总
方法(或 aggregateByKey
)。你只需要编写适当的funtions在每个位置,以获得非空元素。
Is it possible to pivot a table with non-numeric values in Spark Scala? I have reviewed the following two Stack questions.
List in the Case-When Statement in Spark SQL
Following the steps in the "List in the Case-When" question, I can transform my data so that each data type is a column, but there is a row for each entity-data type combination.
id tag value
1 US foo
1 UK bar
1 CA baz
2 US hoo
2 UK hah
2 CA wah
id US UK CA
1 foo
1 bar
1 baz
2 hoo
2 hah
3 wah
Is there a "first non-null" function that can collapse the multiple rows for each entity into just one?
id US UK CA
1 foo bar baz
2 hoo hah wah
You may consider the aggregate
method (or aggregateByKey
). You just need to write the proper funtions to get the non-null element at each position.
这篇关于支点星火斯卡拉非数字表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!