Python Forum
Dataframe extract key values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dataframe extract key values
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Transposing a dataframe without creating NaN values doug2019 2 989 Mar-18-2023, 03:14 PM
Last Post: jefsummers
  Extract parts of multiple log-files and put it in a dataframe hasiro 4 2,096 Apr-27-2022, 12:44 PM
Last Post: hasiro
  Extract parts of a log-file and put it in a dataframe hasiro 4 6,340 Apr-08-2022, 01:18 PM
Last Post: hasiro
  PDF Extract using CSV values atomxkai 5 2,015 Jan-13-2022, 12:20 PM
Last Post: Pedroski55
  List of dataframe values beginning with x,y or z glidecode 3 1,943 Nov-08-2021, 10:16 PM
Last Post: glidecode
  How to sort values descending from a row in a dataframe using python sankarachari 1 1,425 Aug-16-2021, 08:55 AM
Last Post: jamesaarr
  How to get value in Dataframe given row & column values? moonlight 1 2,433 Apr-26-2021, 09:30 PM
Last Post: Larz60+
  Xlsxwriter: Create Multiple Sheets Based on Dataframe's Sorted Values KMV 2 3,502 Mar-09-2021, 12:24 PM
Last Post: KMV
  Pandas Extract data from two dataframe nio74maz 1 2,187 Dec-26-2020, 09:52 PM
Last Post: nio74maz
  xml.etree.ElementTree extract string values matthias100 2 4,991 Jul-12-2020, 06:02 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020