在名为difference
的df中有一个名为surface-wordings
的列,它的值如下所示:
['paths-modified-/clusters/{cluster_id}/hosts/{host_id}/instructions-operations-modified-POST-parameters-modified-body-reply-schema-properties-modified-step_type-enum-deleted']
我定义了一个关键字到标签的映射,我想从这个列中提取关键字并将标签分配给一个名为labels
的新列.映射如下:
keyword_label_mappings = {
'POST-parameters-modified': 'POST Parameters Modified',
'PUT-parameters-modified': 'PUT Parameters Modified',
'POST-responses-modified': 'POST Responses Modified',
'DELETE-summary-from': 'DELETE Summary Changed',
'POST-responses-deleted': 'POST Responses Deleted',
'POST-parameters-added': 'POST Parameters Added',
'POST-parameters-deleted': 'POST Parameters Deleted',
}
我不知道我如何才能做到这一点,任何建议或 idea 都会非常感谢.
编辑:发布print(difference['surface_wordings'].head(5))
的输出以供参考:
surface_wordings
63662 ['openAPI-from', 'openAPI-to', 'paths-added', 'paths-deleted', 'endpoints-added', 'endpoints-deleted', 'servers-deleted', 'components-schemas-deleted']
63661 ['info-title-from', 'info-title-to', 'info-license-deleted', 'info-version-from', 'info-version-to', 'paths-modified-/pets-operations-modified-GET-summary-from', 'paths-modified-/pets-operations-modified-GET-summary-to', 'endpoints-modified-{ method: GET, path: /pets }-summary-from', 'endpoints-modified-{ method: GET, path: /pets }-summary-to']
63659 ['paths-modified-/pets-operations-modified-GET-summary-from', 'paths-modified-/pets-operations-modified-GET-summary-to', 'endpoints-modified-{ method: GET, path: /pets }-summary-from', 'endpoints-modified-{ method: GET, path: /pets }-summary-to']
63658 ['info-version-from', 'info-version-to', 'paths-modified-/pets-operations-modified-GET-summary-from', 'paths-modified-/pets-operations-modified-GET-summary-to', 'endpoints-modified-{ method: GET, path: /pets }-summary-from', 'endpoints-modified-{ method: GET, path: /pets }-summary-to']
63657 ['paths-modified-/pets-operations-modified-GET-summary-from', 'paths-modified-/pets-operations-modified-GET-summary-to', 'endpoints-modified-{ method: GET, path: /pets }-summary-from', 'endpoints-modified-{ method: GET, path: /pets }-summary-to']