Skip to content

Instantly share code, notes, and snippets.

@juriad
Created March 24, 2017 17:06
Show Gist options
  • Select an option

  • Save juriad/e4072b0957d0cdd01dcdda0c819db0d8 to your computer and use it in GitHub Desktop.

Select an option

Save juriad/e4072b0957d0cdd01dcdda0c819db0d8 to your computer and use it in GitHub Desktop.
Sample data for Creditor-Debtor-Amount example
# Original data
# (Creditor, Debtor, Amount)
(James, Mary, 1300)
(Mary, Robert, 2500)
(Mary, Michael, 500)
(Barbara, Linda, 1200)
(Linda, Robert, 300)
# Mapped to two individual records
# (Person, Amount)
(James, 1300)
(Mary, -1300)
(Mary, 2500)
(Robert, -2500)
(Mary, 500)
(Michael, -500)
(Barbara, 1200)
(Linda, -1200)
(Linda, 300)
(Robert, -300)
# Reduced by person
# (Person, Balance)
(James, 1300) # 1300
(Mary, 1700) # -1300 + 2500 + 500
(Robert, -2800) # -2500 + -300
(Michael, -500) # -500
(Barbara, 1200) # 1200
(Linda, 900) # -1200 + 300
# Mapped to buckets
# (Bucket, Constant 1)
(1, 1) # James
(1, 1) # Mary
(-3, 1) # Robert
(-1, 1) # Michael
(1, 1) # Barbara
(0, 1) # Linda
# Reduced by bucket
# (Bucket, # of People)
(1, 3) # 3 people in range [1000, 2000)
(-3, 1) # 1 person in range [-3000, -2000)
(-1, 1) # 1 person in range [-1000, 0)
(0, 1) # person in range [0, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment