code: def states(data):
      by_state = data["with_years_in_prison"].group_by("state")
      state_totals = by_state.aggregate([("count", agate.Count())])
  
      sorted_totals = state_totals.order_by("count", reverse=True)
  
      sorted_totals.print_table(max_rows=5)
  
      medians = by_state.aggregate(
          [
              ("count", agate.Count()),
              (
                  "median_years_in_prison",
                  agate.Median("years_in_prison"),
              ),
          ]
      )
  
      sorted_medians = medians.order_by(
          "median_years_in_prison", reverse=True
      )
  
      sorted_medians.print_table(max_rows=5)
  
file_path: agate/exonerations.py
imports: import proof
  import agate
label_desc: Use image node_id 6 for calling a global function with example usage: states(data) without return types