'Calculating mean in python with np, receiving str attribute error

I'm trying to calculate the mean of data from a csvfile in python. When I put in code, it is returning an attribution error. This is my code:

import csv
import os

userhome = os.path.expanduser('~')
csvfile = userhome + r'/Desktop/Week2Milestone.csv'
with open(csvfile, 'r') as data:
    for line in csv.DictReader(data):
        print(line)
    
import numpy as np
child_mean = np.mean(csvfile.childs)

This is the error I receive:

child_mean = np.mean(csvfile.childs)

AttributeError: 'str' object has no attribute 'childs'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source