pyspark中是否有用于指定列名的通用函数?

pyspark中是否有用于指定列名的通用函数?,pyspark,Pyspark,pyspark中是否有指定列名的通用函数?而不是_1、_2、_3。。。。。。。它必须给出col_1,col_2,col_3 +---+---+---+---+---+---+---+---+---+---+---+---+ | _1| _2| _3| _4| _5| _6| _7| _8| _9|_10|_11|_12| +---+---+---+---+---+---+---+---+---+---+---+---+ | 0| 0| 0| 1| 0| 1| 0| 0| 0|

pyspark中是否有指定列名的通用函数?而不是_1、_2、_3。。。。。。。它必须给出col_1,col_2,col_3

+---+---+---+---+---+---+---+---+---+---+---+---+
| _1| _2| _3| _4| _5| _6| _7| _8| _9|_10|_11|_12|
+---+---+---+---+---+---+---+---+---+---+---+---+
|  0|  0|  0|  1|  0|  1|  0|  0|  0|  1|  0|   |
|  0|  0|  0|  1|  0|  1|  0|  0|  0|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  0|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  1|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  1|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  1|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  1|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  1|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  1|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  1|   |
|  0|  0|  0|  0|  0|  1|  1|  0|  1|  1|  1|   |
+---+---+---+---+---+---+---+---+---+---+---+---+
only showing top 20 rows
试试这个-

df.toDF(*[“col{}”.format(i)表示范围(1,len(df.columns)+1)])

df_split=index.select(sf.split(index.binary,”)).rdd.flatMap(lambda X:X).toDF(*[“col{}”.format(i)表示范围(1,len(index.columns)+1)])内的i,方法是尝试下面的错误类型error:toDF()表示1到3个位置参数,但有10个位置参数given@mounikareddy,
.toDF(..)
是来自数据帧而不是来自RDD的方法。不确定为什么要将DF转换为RDDim新cto pyspark“DataFrame”对象没有属性“flatMap”,所以我使用rdd