【发布时间】:2020-01-04 03:39:55
【问题描述】:
我是 scala、spark 的新手,在尝试从一些玩具数据帧中学习时遇到了问题。
我有一个包含以下两列的数据框:
Name_Description Grade
Name_Description 是一个数组,Grade 只是一个字母。这是我遇到问题的 Name_Description。在 Spark 上使用 scala 时,我正在尝试更改此列。
名称描述不是一个固定大小的数组。可能是这样的
['asdf_布兰登', 'Ca%abc%rd'] ['fthhhhChris', 'Rock', '是%abc%man']
唯一的问题如下:
1. the first element of the array ALWAYS has 6 garbage characters, so the real meaning starts at 7th character.
2. %abc% randomly pops up on elements, so I wanna erase them.
有没有办法在 Scala 中实现这两件事?例如,我只想
['asdf_ Brandon', 'Ca%abc%rd'], ['fthhhhChris', 'Rock', 'is the %abc%man']
改成
['Brandon', 'Card'], ['Chris', 'Rock', 'is the man']
【问题讨论】:
-
那么
Name_Description是一个字符串数组吗? -
@KrzysztofAtłasik Name_Description 的每一行都是一个字符串数组。 ['asdf_ Brandon', 'Ca%abc%rd'] ['fthhhhChris', 'Rock', 'is the %abc%man'] 代表两行Name_Description
标签: scala dataframe apache-spark