divider by age

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Age, Workclass, Fnlwgt, Education, Educationnum, Maritalstatus, Occupation, Relationship, Race, Sex, Capitalgain, Capitalloss, Hoursperweek, Nativecountry, Class
f = open('t', 'w')
for line in open('train.csv'):
line = line[:-1].split(',')
if len(line) < 1:
continue
if line[0] == '?':
line = ','.join(line)
print line
age = int(line[0])
if age in range(25): age = '0025'
if age in range(25, 40): age = '2639'
if age in range(40, 60): age = '4059'
if age in range(60, 80): age = '6080'
if age in range(80, 120): age = '8080'
line[0] = age
line = ','.join(line)
f.write(line+'\n')