-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday9.py
31 lines (23 loc) · 912 Bytes
/
day9.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Challenge
Fill out the missing values in the monthly milk production column with the median, and fill out the number of cows column using the ffill method.
After filling in the missing values with our new data, answer these questions for Dot, so they can figure out the value of having a cow year-round:
1. What is the average for monthly milk production?
2. What is the standard deviation for monthly milk production?
3. What is the average number of cows used?
"""
import pandas as pd
from math import sqrt
from formatter import decimal
df = pd.read_csv('data/milk_2.csv')
ppcName = 'Monthly milk production: pounds per cow'
ppc = df[ppcName].map(float)
ppc = ppc.fillna(ppc.median())
a1 = ppc.mean()
a2 = ppc.std()
nocName = 'Number of Cows'
noc = df[nocName].map(float).fillna(method='ffill')
a3 = noc.mean()
print("Q1:", decimal(a1, 4))
print("Q2:", decimal(a2, 4))
print("Q3:", decimal(a3, 4))