我有一个 PySpark Dataframe
有一列 strings
。如何检查其中的哪些行是数字。我在 PySpark 的 官方文档 中找不到任何功能。
values = [('25q36',),('75647',),('13864',),('8758K',),('07645',)]
df = sqlContext.createDataFrame(values,['ID',])
df.show()
+-----+
| ID|
+-----+
|25q36|
|75647|
|13864|
|8758K|
|07645|
+-----+
In Python, there is a function .isDigit()
which returns True
or False
if the string
contains just numbers or not.
预期的数据帧:
+-----+-------+
| ID| Value |
+-----+-------+
|25q36| False |
|75647| True |
|13864| True |
|8758K| False |
|07645| True |
+-----+-------+
我想避免创建 UDF
。
原文由 cph_sto 发布,翻译遵循 CC BY-SA 4.0 许可协议
一个简单的演员就可以完成这项工作: