在比较数据框列值时处理 JIRA 下拉 None 选项

Handling JIRA dropdown None option while comparing a dataframe column value

我在将 JIRA 保管箱字段中的 None(默认)选项与数据框列进行比较时遇到问题。

issue.raw['fields'][result]['value'] != df.RESULT.values[0]

issue.raw['fields'][结果]['value'] 是 None,这是在保管箱中设置的默认值。对于在保管箱中选择 None 作为选项的所有 JIRA,我都面临这个问题。

我看到的错误是-

TypeError: 'NoneType' object is not subscriptable

请告知如何处理此类 None 选项。

当您尝试使用括号表示法访问不是列表的内容时,会发生 TypeError: 'NoneType' object is not subscriptable 异常。 (即 obj[1])。

据了解,您的代码错误可能由以下原因引起:

  1. issue.raw['fields'] 是 None,因此 issue.raw['fields'][result] 导致错误。

  1. df.RESULT.values 是 None 并且 df.RESULT.values[0] 导致错误。

假设您的 DataFrame df 结构正确,错误来自选项 1 并且您的代码可以通过以下验证得到修复:

if issue.raw['fields'] is None:
    # Create a field List
    # Create a field with a value same as DataFrame's value
elif issue.raw['fields'][result]['value'] != df.RESULT.values[0]:
    # Update field value with DataFrame's value