Python Forum

Full Version: Dataframe extract key values
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Given:
you have two columns ID , Status

ID 1 has the following Status value
Output:
[ { 'id': 0, 'name': 'PASS', 'description': 'The test run has passed', 'isFinal': True, 'color': '#95C160', 'isNative': True, 'statusCount': 1, 'statusPercent': 100.0 }, { 'id': 3, 'name': 'FAIL', 'description': 'The test run has failed', 'isFinal': True, 'color': '#D45D52', 'isNative': True, 'statusCount': 0, 'statusPercent': 0.0 }, { 'id': 4, 'name': 'ABORTED', 'description': 'The test run was aborted', 'isFinal': True, 'color': '#111111', 'isNative': True, 'statusCount': 0, 'statusPercent': 0.0 } similarily ID 2 has the following status value: [ { 'id': 0, 'name': 'PASS', 'description': 'The test run has passed', 'isFinal': True, 'color': '#95C160', 'isNative': True, 'statusCount': 2, 'statusPercent': 100.0 }, { 'id': 3, 'name': 'FAIL', 'description': 'The test run has failed', 'isFinal': True, 'color': '#D45D52', 'isNative': True, 'statusCount': 3, 'statusPercent': 0.0 }, { 'id': 4, 'name': 'ABORTED', 'description': 'The test run was aborted', 'isFinal': True, 'color': '#111111', 'isNative': True, 'statusCount': 4, 'statusPercent': 0.0 }
whats needed is:

ID PASS FAIL ABORTED
---------------------------
1 1 0 0
2 2 3 4

'statusCount' is the value used to fill out pass,fail ad aborted counts
and
'name' key became column name

Note: checked type of 'status' calumn - it is series

thanks in advance