我怎样才能从 'pyspark.sql.types.Row' 得到所有 columns/attributes 的名字?

How can I get from 'pyspark.sql.types.Row' all the columns/attributes name?

我正在使用 Python API 的 Spark 版本 1.4.1。

我的行对象如下所示:

row_info = Row(name = Tim, age = 5, is_subscribed = false)

我怎样才能得到对象属性的列表? 类似于:["name", "age", "is_subscribed"]

如果您不关心顺序,您可以简单地从 dict:

中提取这些
list(row_info.asDict())

否则我知道的唯一选择是直接使用 __fields__:

row_info.__fields__