Skip to content

Instantly share code, notes, and snippets.

@wolframalpha
Created July 25, 2019 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolframalpha/597ddd5543cca662fbbd46ad6db8cfd3 to your computer and use it in GitHub Desktop.
Save wolframalpha/597ddd5543cca662fbbd46ad6db8cfd3 to your computer and use it in GitHub Desktop.
import re
def get_buckets(statuses):
status_bucket = []
for status in statuses:
dpd = re.search('(\d+) (or above )?day', status, re.IGNORECASE)
if dpd:
dpd = int(dpd.groups()[0])
if dpd <= 30:
status_bucket.append('SMA-0')
elif dpd <= 60:
status_bucket.append('SMA-1')
elif dpd <= 90:
status_bucket.append('SMA-2')
elif dpd > 90:
status_bucket.append('NPA')
elif re.search('SMA-\d', status, re.IGNORECASE):
status_bucket.append(re.search('SMA-\d', dpd, re.IGNORECASE)[0])
else:
status_bucket.append(status)
return status_bucket
status = ['22 Days Past Due',
'0 Day Past Due',
'54 Days Past Due',
'Sub-standard',
'12 Days Past Due',
'26 Days Past Due',
'118 Days Past Due',
'1 Day Past Due',
'8 Days Past Due',
'Doubtful']
get_buckets(status)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment