Guest User

Untitled

a guest
Dec 12th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. conviction_record_clearable_outcomes = [] # list of outcomes for each charge
  2.  
  3. condition_for_clearability = None # define variable and set it to None
  4. conditions_for_clearability = [] # list of conditions for each charge
  5.  
  6. current_date = datetime(2018, 11, 15)
  7.  
  8. for charge_detail in df_expungement.itertuples():
  9. conviction_record_clearable = np.NaN # need these to go back to null on each iteration
  10. condition_for_clearability = np.NaN # need these to go back to null on each iteration
  11. person_id = charge_detail[1]
  12. charge_normalization = charge_detail[2]
  13. charge_type_normalization = charge_detail[3]
  14. disposition_normalization = charge_detail[4]
  15. is_most_recent_conviction = charge_detail[5]
  16. disposition_date = charge_detail[6]
  17. sentencing_length_days = charge_detail[7]
  18.  
  19. # 1- if the person was found not guilty, then you don’t have to analyze it. We are capturing this data a different way.
  20. if disposition_normalization == 'not guilty':
  21. conviction_record_clearable = 0
  22. condition_for_clearability = 1
  23.  
  24. # 2- CRS 24-72-704, if a person who is convicted of a drug related petty offense, misdemeanor, or felony (not for the sale or
  25. # distribution of drugs) between July 1, 2008 and July 1, 2011 and has gone 10 years without a charge or conviction, original
  26. # conviction can be sealable.
  27. elif charge_normalization == "drug_poss" and disposition_date + timedelta(days=sentencing_length_days) < current_date and is_most_recent_conviction == 1 and charge_type_normalization in ['C1', 'C2_M', 'C2_PO', 'C2_T', 'C3', 'M', 'F5', 'F6'] and datetime(2008, 7, 1) < disposition_date < datetime(2011, 7, 1):
  28. conviction_record_clearable = 1
  29. condition_for_clearability = 2
  30.  
  31. # 3- CRS 24-72-704, if this type of offense occurred before July 1, 2008 the conviction needs prosecutor approval to be sealable.
  32. elif disposition_date < datetime(2008, 7, 1):
  33. conviction_record_clearable = 1
  34. condition_for_clearability = 3
  35.  
  36. # 4- for petty offense, level 2 and 3 misdemeanors (including drug misdemeanors), convicted must go 3 years without charge or conviction
  37. elif charge_type_normalization in ['C2_PO', 'C2-M', 'C2_T', 'M3'] and disposition_date + timedelta(days=1095) < current_date and disposition_date + timedelta(days=sentencing_length_days) < current_date and charge_normalization == 'drug_distribute':
  38. conviction_record_clearable = 1
  39. condition_for_clearability = 4
  40.  
  41. #5- for level 1 misdemeanors (including drug misdemeanors), convicted must go 5 years without charge or conviction
  42. elif charge_type_normalization == 'M1' and disposition_date + timedelta(days=1825) < current_date and disposition_date + timedelta(days=sentencing_length_days) < current_date and is_most_recent_conviction == 1:
  43. conviction_record_clearable = 1
  44. condition_for_clearability = 5
  45.  
  46. #6- for level 4, 5, and 6 drug felonies, convicted must go 7 years without charge or conviction
  47. elif charge_type_normalization in ['F4', 'F5', 'F6'] and disposition_date + timedelta(days=2555) < current_date and disposition_date + timedelta(days=sentencing_length_days) < current_date and is_most_recent_conviction == 1 and disposition_date > datetime(2011, 7, 1):
  48. conviction_record_clearable = 1
  49. condition_for_clearability = 6
  50.  
  51. #7- for all other drug related offense not covered, after 10 years without charge or conviction the records can be sealable.
  52. elif charge_normalization == 'drug_poss' and disposition_date + timedelta(days=3650) < current_date and disposition_date + timedelta(days=sentencing_length_days) < current_date and is_most_recent_conviction == 1:
  53. conviction_record_clearable = 1
  54. condition_for_clearability = 7
  55.  
  56. #8- for all other instances
  57. else:
  58. conviction_record_clearable = 0
  59. condition_for_clearability = 8
  60.  
  61. # append the conviction_record_clearable 1 or 0 value to conviction_record_clearable_outcomes
  62. conviction_record_clearable_outcomes.append(conviction_record_clearable)
  63. conditions_for_clearability.append(condition_for_clearability)
Add Comment
Please, Sign In to add comment