如何处理 pyspark 中的转义字符。尝试用 NULL 替换转义字符
我正在尝试用 pyspark 数据框中的 NULL 替换转义字符。 Dataframe 中的数据看起来像下面的
Col1|Col2|Col3
1|\026\026|026|abcd026efg.
Col2 是垃圾数据并尝试用 NULL 替换。尝试使用replace和regex_replace函数将'\026'替换为Null值,由于转义字符(“\”),数据没有替换为NULL值。
replace(col2, "026", 'abcd')
replace(Col2, "\026", 'abcd')
最后,
我希望我的数据能够
Col1|Col2|Col3
1|NULL|026|abcd026efg.
高度赞赏解决这种情况的想法。
谢谢 -EVR
I'm trying to replace a escape character with NULL in pyspark dataframe. Data in dataframe looks like below
Col1|Col2|Col3
1|\026\026|026|abcd026efg.
Col2 is a garbage data and trying to replace with NULL. Tried replace and regex_replace functions to replace '\026' with Null value, because of escape character (" \ "), data is not replaced with NULL value.
replace(col2, "026", 'abcd')
replace(Col2, "\026", 'abcd')
Finally,
I want my data as
Col1|Col2|Col3
1|NULL|026|abcd026efg.
Highly appreciate for thoughts to resolve this scenario.
Thanks
-EVR
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用替换所有数字和前面的非数字
Use replace all digits and preceding non digits