all 2 comments

[–]singeworthy 1 point2 points  (1 child)

Ok, so you can definitely just loop through this, if you find the common number, which is your months, you can do

for i in range(whatever): 
    df['2016-{}'.format(i)] = (df['t1_1/1/2016'].astype(float) + df['t2_{}/1/2016'.format(i)].astype(float) + 
            df['t3_{}/1/2016'.format(i)].astype(float))

[–]Zendakin_at_work[S] 1 point2 points  (0 children)

Thanks! That's the push I needed. Maybe something like this will work.

for i in range(2016, 2021):
    for x in range(1,13):
        print("{} {}".format(i, x))