如何做到在绑定2 sparkR数据框列? [英] How to do bind two dataframe columns in sparkR?

查看:151
本文介绍了如何做到在绑定2 sparkR数据框列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何绑定数据框中的两列SparkR火花1.4

How to bind two columns of dataframe in SparkR of spark 1.4

TIA,阿伦

推荐答案

有没有办法做到这一点。这里是Scala中的火花(1.3)的问题。唯一的办法是能够做到这一点,是有某种row.numbering的,因为这样你能够参加在row.number。为什么?因为你只能加入表或添加列基于其他现有栏目

There is no way to do this. Here is a question on spark (1.3) in scala. The only way to be able to do this, is having some kind of row.numbering, because then you are able to join on row.number. Why? Because you can only join tables or add columns based on other already existing columns

data1 <- createDataFrame(sqlContext, data.frame(a=c(1,2,3)))
data2 <- createDataFrame(sqlContext, data.frame(b=c(2,3,4)))

然后

withColumn(data1,"b",data1$a + 1)

是允许的,但

withColumn(data1,"b",data2$b)

不是。从目前星火削减你的数据帧中的块存储,它不知道如何绑定他们的(它没有连续测序想法),只有当你有row.numbers。

is not. From the moment Spark cuts your DataFrame in blocks to store it, it has no idea how to bind them (it has no idea of a row sequencing), only when you have row.numbers.

这篇关于如何做到在绑定2 sparkR数据框列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆