This is my Dataframe:
entityId delta_approved_clockout
(ID: 10) 247333605 0.0
(ID: 20) 36738870 0.0
(ID: 40) 4668036427 0.0
(ID: 50) 1918647972 0.0
(ID: 60) 4323165902 44125.0
(ID: 80) 145512255 0.0
Assigned (ID: 30) 42050340 0.0
Assigned (ID: 40) 130880371376 0.0
Assigning (ID: 30) 1095844753 0.0
Cancelled (ID: 40) 937280 0.0
Cancelled (ID: 80) 16857720813 0.0
Planned (ID: 20) 9060392597 0.0
Planning (ID: 10) 108484297031 0.0
Processed (ID: 70) 133289880880 0.0
Revoked (ID: 50) 2411903072 0.0
Writing (ID: 50) 146408550024 0.0
Written (ID: 60) 139458227923 1018230.0
I want the result to only print the exact regex match for '(ID: 10)', using this line my input includes 'Planning (ID: 10)', which is not the exact match I need. These are the summed results:
entityId delta_approved_clockout
last_status
(ID: 10) 247333605 0.0
Planning (ID: 10) 108484297031 0.0
print input_data[input_data['last_status'].str.contains(r'(?<!\S)\(ID: 10\)(?!\S)', na=False)]
I have also tried regex codes that gave 0 results such as:
print input_data[input_data['last_status'].str.contains(r' ^(\(ID: \d+\))$', na=False)]
print input_data[input_data['last_status'].str.contains(r'^(\(ID: 10\))$', na=False)]
Perhaps I don't understand regex thoroughly, what would be the correct way of writing regex? Thanks in advance.
r'^\s*(\(ID:\s*\d+\))\s*$'df=df['last_status' == '(ID: 10)']()