In [2]:
import csv
import pandas as pd
In [87]:
data = {
    'periods': 'jan	feb	mar	apr	may	jun	jul	aug	sep	oct',
    'retention': '100%	40%	30%	20%	15%	10%	10%	10%	10%	10%',
    'new_users': '1000	2000	3000	4000	5000	5000	5000	5000	5000	5000'
}
In [88]:
df = pd.DataFrame({
    'New users': list(map(int, data['new_users'].split('\t'))), 
    'Retention': list(map(lambda x: float(x.rstrip('%')) / 100, data['retention'].split('\t')))
})
df
Out[88]:
New users Retention
0 1000 1.00
1 2000 0.40
2 3000 0.30
3 4000 0.20
4 5000 0.15
5 5000 0.10
6 5000 0.10
7 5000 0.10
8 5000 0.10
9 5000 0.10
In [89]:
months = data['periods'].split('\t')

for month_number, row in df.iterrows():
    previous_auditory = 0
    for previous_month_number, previous_row in df.iterrows():
        if month_number == previous_month_number:
            break
        month_diff = month_number - previous_month_number
        month_diff_retention = df['Retention'][month_diff]
        previous_auditory += month_diff_retention * previous_row['New users']
        
    mau = row['New users'] + previous_auditory
    print(months[month_number], mau)
jan 1000.0
feb 2400.0
mar 4100.0
apr 6000.0
may 8050.0
jun 9200.0
jul 10050.0
aug 10700.0
sep 11250.0
oct 11750.0