Nel*_*le 1 prefixes apache-spark apache-spark-sql pyspark
我的 Spark 数据帧df的列名称是:A_x1、A_x2、B_x1、B_x2、C_x1、C_x2。
如何使用前缀从df创建 3 个新的 Spark 数据帧?输出应如下所示:
谢谢你!
您可以使用colRegex过滤列:
A_ = df.select(df.colRegex('`A_.*`'))
B_ = df.select(df.colRegex('`B_.*`'))
C_ = df.select(df.colRegex('`C_.*`'))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1160 次 |
| 最近记录: |