Problem: Code a program that opens a tsv file and calculated the mean age of female.
I opened it with this code:
['age', 'gender']
['20', 'female']
['30', 'female']
['21', 'female']
['23', 'female']
['30', 'female']
['25', 'female']
['13', 'female']
['19', 'female']
['16', 'female']
['25', 'female']
['20', 'female']
['25', 'male']
['27', 'male']
['43', 'male']
How do I continue to only get the median of the "age" row?
for number in age:
??
Do I need to import statistics to make it easier to get the mean? (with statistics.mean())
I need to define number and age first too.. I'm not really sure how to start with this
I opened it with this code:
import csv with open("047.tsv") as tsvfile: tsvreader = csv.reader(tsvfile, delimiter="\t") for line in tsvreader: print (line[1:])And it prints something like this:
['age', 'gender']
['20', 'female']
['30', 'female']
['21', 'female']
['23', 'female']
['30', 'female']
['25', 'female']
['13', 'female']
['19', 'female']
['16', 'female']
['25', 'female']
['20', 'female']
['25', 'male']
['27', 'male']
['43', 'male']
How do I continue to only get the median of the "age" row?
for number in age:
??
Do I need to import statistics to make it easier to get the mean? (with statistics.mean())
I need to define number and age first too.. I'm not really sure how to start with this