访问数据帧架构中的元素

2024-04-27 00:43:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个数据帧df,它的模式看起来像-

root
 |-- users: array (nullable = true)
 |    |-- element: struct (containsNull = true)
 |    |    |-- id: string (nullable = true)
 |    |    |-- ok: boolean (nullable = true)
 |    |    |-- attributes: struct (nullable = true)
 |    |    |    |-- array1: array (nullable = true)
 |    |    |    |    |-- element: string (containsNull = true)
 |    |    |    |-- groupid: string (nullable = true)
 |    |    |    |-- array2: array (nullable = true)
 |    |    |    |    |-- element: string (containsNull = true)
 |    |    |    |-- array3: array (nullable = true)
 |    |    |    |    |-- element: string (containsNull = true)
 |    |    |    |-- array4: array (nullable = true)
 |    |    |    |    |-- element: string (containsNull = true)

我想访问和分析array1、array2、array3、array4的值。 我正在尝试:

df.users.attributes.array1

它给了我一个错误-

  AttributeError: 'Series' object has no attribute 'attributes'

如何访问这些数组(array1、array2、array3和array4)中的值/数据?你知道吗


Tags: 数据truedfstringelementarrayusersstruct