Lambda 函数到 groupby 第一个子字符串?
我正在尝试编写一个 lambda 函数,根据单词的第一个子字符串对单词进行分组 所以这些词就像“
a,word
b,can
a,eat
c,vegetables
b,if
到目前为止我有一个 lambda 函数
combineddatardd.combineByKey(lambda v:\[v\],lambda x,y:x+\[y\],lambda x,y:x+y).
combineddatardd.pprint(10)
但这只会给我带来不想要的结果”。 结果需要是:
a,word
a,eat
b,can
b,if
c,vegetables
I am trying to write a lambda function that groups words based on their first substring
So the words are coming in like
a,word
b,can
a,eat
c,vegetables
b,if
So far I have a lambda function
combineddatardd.combineByKey(lambda v:\[v\],lambda x,y:x+\[y\],lambda x,y:x+y).
combineddatardd.pprint(10)
But this only gives me not the result I want.
The outcome needs to be :
a,word
a,eat
b,can
b,if
c,vegetables
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论