Challenge: First Levene's Test
Aufgabe
Swipe to start coding
In this task, you need to read the files and perform a Levene's test on the 'Purchase'
column. Is there a statistical difference between the variances?
- Import
levene
test. - Do the Levene's test.
Lösung
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Import libraries
import pandas as pd
from scipy.stats import levene
# Read .csv files
df_control = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_control.csv', delimiter=';')
df_test = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_test.csv', delimiter=';')
# Do Levene's test
statistic, p_value = levene(df_control['Purchase'], df_test['Purchase'])
# Print result of Levene's test
print('Statistic:', statistic)
print('p-value:', p_value)
# Determine whether the variances are similar
if p_value > 0.05:
print('The variances of the two groups are NOT statistically different')
else:
print('The variances of the two groups are statistically different')
War alles klar?
Danke für Ihr Feedback!
Abschnitt 3. Kapitel 5
single
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Import libraries
import pandas as pd
from ___ import ___
# Read .csv files
df_control = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_control.csv', delimiter=';')
df_test = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_test.csv', delimiter=';')
# Do Levene's test
statistic, p_value = ___(df_control['Purchase'], df_test['Purchase'])
# Print result of Levene's test
print('Statistic:', statistic)
print('p-value:', p_value)
# Determine whether the variances are similar
if p_value > 0.05:
print('The variances of the two groups are NOT statistically different')
else:
print('The variances of the two groups are statistically different')
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen