-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2sample
More file actions
27 lines (21 loc) · 690 Bytes
/
Copy path2sample
File metadata and controls
27 lines (21 loc) · 690 Bytes
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
import pandas as pd
import numpy as np
from scipy.stats import ttest_ind
# Load dataset
df = pd.read_csv("weather.csv")
# Select two groups
group1 = df[df["Condition"] == "Sunny"]["Data.Temperature.Avg Temp"].dropna()
group2 = df[df["Condition"] == "Rain"]["Data.Temperature.Avg Temp"].dropna()
# Sample statistics
print("Group 1 Mean:", group1.mean())
print("Group 2 Mean:", group2.mean())
# Independent t-test
t_stat, p_value = ttest_ind(group1, group2)
print("\nt-statistic:", t_stat)
print("p-value:", p_value)
# Decision
alpha = 0.05
if p_value < alpha:
print("Reject Null Hypothesis (Means are different)")
else:
print("Fail to Reject Null Hypothesis (Means are same)")