Skip to content

Instantly share code, notes, and snippets.

@vsoch
Last active July 29, 2019 20:07
Show Gist options
  • Save vsoch/b86537e3b9171a2292e0587f20bd47fe to your computer and use it in GitHub Desktop.
Save vsoch/b86537e3b9171a2292e0587f20bd47fe to your computer and use it in GitHub Desktop.
A quick script to parse the (now deprecated) member counts data (memberCounts.csv) into "memberCountsHistorical.csv" that will be used to populate the chart in the site, and updated to include the current count data. The input file has a record of every date, while the output has month/year dates paired with running total for each.
import pandas
# This script will parse the historical data,
# and return a lookup of monthly dates with counts.
df = pandas.read_csv('memberCounts.csv')
counts = dict()
# Put dates and counts for each into lookup
for date in df['date'].tolist():
date = date.split('/')
date = "%s/%s" %(date[0], date[-1]) # month / year
if date not in counts:
counts[date] = 0
counts[date]+=1
# Update to be a running total
total = 0
for date, count in counts.items():
total = total + count
counts[date] = total
# Save to csv
with open('memberCountsHistorical.csv', 'w') as filey:
filey.write('date,total\n')
for date, count in counts.items():
filey.write('%s,%s\n' %(date, count))
date total
2/8/2018 1
2/14/2018 2
3/5/2018 3
4/11/2018 4
5/10/2018 5
6/5/2018 6
11/13/2018 7
11/16/2018 8
11/27/2018 9
1/30/2019 10
2/21/2019 11
3/7/2019 12
3/7/2019 13
3/7/2019 14
3/8/2019 15
3/8/2019 16
3/11/2019 17
3/11/2019 18
3/25/2019 19
3/25/2019 20
4/5/2019 21
4/9/2019 22
4/9/2019 23
4/11/2019 24
4/19/2019 25
4/19/2019 26
4/23/2019 27
4/24/2019 28
4/25/2019 29
5/3/2019 30
5/5/2019 31
5/6/2019 32
5/7/2019 33
5/8/2019 34
5/8/2019 35
5/9/2019 36
5/13/2019 37
5/14/2019 38
5/17/2019 39
5/17/2019 40
5/18/2019 41
5/21/2019 42
5/22/2019 43
5/30/2019 44
5/31/2019 45
5/31/2019 46
6/1/2019 47
6/1/2019 48
6/3/2019 49
6/3/2019 50
6/4/2019 51
6/4/2019 52
6/4/2019 53
6/4/2019 54
6/4/2019 55
6/4/2019 56
6/4/2019 57
6/6/2019 58
6/6/2019 59
6/6/2019 60
6/6/2019 61
6/10/2019 62
6/10/2019 63
6/10/2019 64
6/10/2019 65
6/10/2019 66
6/10/2019 67
6/10/2019 68
6/10/2019 69
6/10/2019 70
6/10/2019 71
6/11/2019 72
6/11/2019 73
6/12/2019 74
6/12/2019 75
6/12/2019 76
6/14/2019 77
6/15/2019 78
6/18/2019 79
6/18/2019 80
6/18/2019 81
6/19/2019 82
6/22/2019 83
6/22/2019 84
6/28/2019 85
7/2/2019 86
7/2/2019 87
7/2/2019 88
7/2/2019 89
7/2/2019 90
7/2/2019 91
7/2/2019 92
7/2/2019 93
7/2/2019 94
7/2/2019 95
7/2/2019 96
7/3/2019 97
7/3/2019 98
7/8/2019 99
7/8/2019 100
7/8/2019 101
7/10/2019 12
7/10/2019 103
7/10/2019 104
7/11/2019 105
7/11/2019 106
7/12/2019 17
7/13/2019 108
7/15/2019 109
7/15/2019 110
7/16/2019 111
7/17/2019 112
7/17/2019 113
7/18/2019 114
7/18/2019 115
7/18/2019 116
7/18/2019 117
7/18/2019 118
7/18/2019 119
7/19/2019 120
7/20/2019 121
7/20/2019 122
7/22/2019 123
7/23/2019 124
7/24/2019 125
7/24/2019 126
7/24/2019 127
7/25/2019 128
7/25/2019 129
7/26/2019 130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment