Skip to content

Instantly share code, notes, and snippets.

@gabrielgrant
Last active November 24, 2015 17:57
Show Gist options
  • Save gabrielgrant/8a7e57bb5613a5b7ee62 to your computer and use it in GitHub Desktop.
Save gabrielgrant/8a7e57bb5613a5b7ee62 to your computer and use it in GitHub Desktop.
Estimated Calorie Needs per Day by Age, Gender, and Physical Activity Level.

Estimated Calorie Needs per Day by Age, Gender, and Physical Activity Level

Based on USDA guidelines: http://www.cnpp.usda.gov/sites/default/files/usda_food_patterns/EstimatedCalorieNeedsPerDayTable.pdf

Estimated amounts of caloriesa needed to maintain calorie balance for various gender and age groups at three different levels of physical activity. The estimates are rounded to the nearest 200 calories for assignment to a USDA Food Pattern. An individual’s calorie needs may be higher or lower than these average estimates.

age_low age_high male_low_activity male_moderate_activity male_high_activity female_low_activity female_moderate_activity female_high_activity
0 2 1000 1000 1000 1000 1000 1000
3 3 1200 1400 1400 1000 1200 1400
4 4 1200 1400 1600 1200 1400 1400
5 5 1200 1400 1600 1200 1400 1600
6 6 1400 1600 1800 1200 1400 1600
7 7 1400 1600 1800 1200 1600 1800
8 8 1400 1600 2000 1400 1600 1800
9 9 1600 1800 2000 1400 1600 1800
10 10 1600 1800 2200 1400 1800 2000
11 11 1800 2000 2200 1600 1800 2000
12 12 1800 2200 2400 1600 2000 2200
13 13 2000 2200 2600 1600 2000 2200
14 14 2000 2400 2800 1800 2000 2400
15 15 2200 2600 3000 1800 2000 2400
16 16 2400 2800 3200 1800 2000 2400
17 17 2400 2800 3200 1800 2000 2400
18 18 2400 2800 3200 1800 2000 2400
19 20 2600 2800 3000 2000 2200 2400
21 25 2400 2800 3000 2000 2200 2400
26 30 2400 2600 3000 1800 2000 2400
31 35 2400 2600 3000 1800 2000 2200
36 40 2400 2600 2800 1800 2000 2200
41 45 2200 2600 2800 1800 2000 2200
46 50 2200 2400 2800 1800 2000 2200
51 55 2200 2400 2800 1600 1800 2200
56 60 2200 2400 2600 1600 1800 2200
61 65 2000 2400 2600 1600 1800 2000
66 70 2000 2200 2600 1600 1800 2000
71 75 2000 2200 2600 1600 1800 2000
76 1000 2000 2200 2400 1600 1800 2000
import csv
r = list(csv.DictReader(open('/tmp/calories.csv')))
def get_by_age(age):
for row in r:
if age in range(row['age_low'], row['age_high']):
return row
# copied from http://www.cnpp.usda.gov/sites/default/files/usda_food_patterns/EstimatedCalorieNeedsPerDayTable.pdf
s = """2 1,000 1,000 1,000 1,000 1,000 1,000
3 1,200 1,400 1,400 1,000 1,200 1,400
4 1,200 1,400 1,600 1,200 1,400 1,400
5 1,200 1,400 1,600 1,200 1,400 1,600
6 1,400 1,600 1,800 1,200 1,400 1,600
7 1,400 1,600 1,800 1,200 1,600 1,800
8 1,400 1,600 2,000 1,400 1,600 1,800
9 1,600 1,800 2,000 1,400 1,600 1,800
10 1,600 1,800 2,200 1,400 1,800 2,000
11 1,800 2,000 2,200 1,600 1,800 2,000
12 1,800 2,200 2,400 1,600 2,000 2,200
13 2,000 2,200 2,600 1,600 2,000 2,200
14 2,000 2,400 2,800 1,800 2,000 2,400
15 2,200 2,600 3,000 1,800 2,000 2,400
16 2,400 2,800 3,200 1,800 2,000 2,400
17 2,400 2,800 3,200 1,800 2,000 2,400
18 2,400 2,800 3,200 1,800 2,000 2,400
19–20 2,600 2,800 3,000 2,000 2,200 2,400
21–25 2,400 2,800 3,000 2,000 2,200 2,400
26–30 2,400 2,600 3,000 1,800 2,000 2,400
31–35 2,400 2,600 3,000 1,800 2,000 2,200
36–40 2,400 2,600 2,800 1,800 2,000 2,200
41–45 2,200 2,600 2,800 1,800 2,000 2,200
46–50 2,200 2,400 2,800 1,800 2,000 2,200
51–55 2,200 2,400 2,800 1,600 1,800 2,200
56–60 2,200 2,400 2,600 1,600 1,800 2,200
61–65 2,000 2,400 2,600 1,600 1,800 2,000
66–70 2,000 2,200 2,600 1,600 1,800 2,000
71–75 2,000 2,200 2,600 1,600 1,800 2,000
76+ 2,000 2,200 2,400 1,600 1,800 2,000"""
s2 = s.split('\n')
data = []
for line in s2:
age, counts = line.split()[0], line.split()[1:]
if '–' in age:
low, high = age.split('–')
elif age == '2':
low = 0
high = age
elif '+' in age:
low = age.replace('+', '')
high = 1000
else:
low, high = age, age
counts = [int(c.replace(',', '')) for c in counts]
data.append([int(low), int(high)] + counts)
import csv
csv.writer(open('/tmp/calories.csv', 'w')).writerows(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment