I am trying to get calculate the mean for Score 1 only if column Dates
is equal to Oct-16
:
What I originally tried was:
import pandas as pd
import numpy as np
import os
dataFrame = pd.read_csv("test.csv")
for date in dataFrame["Dates"]:
if date == "Oct-16":
print(date)##Just checking
print(dataFrame["Score 1"].mean())
But my results are the mean for the whole column Score 1
Another thing I tried was manually telling it which indices to calculate the mean for:
dataFrame["Score 1"].iloc[0:2].mean()
But ideally I would like to find a way to do it if Dates == "Oct-16"
.