Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Descriptive Stats | Normality Check
The Art of A/B Testing

book
Challenge: Descriptive Stats

We will remind you of some descriptive statistics:

  • count - the number of observations in the sample;

  • mean - the sum of the values ​​of all observations divided by their number;

  • std - the square root of the variance, which characterizes the degree of deviation of the data from the average value of the sample;

  • median - central value that divides the sample into two equal parts;

  • min - the smallest sample value;

  • max - the largest sample value.

Tâche

Swipe to start coding

In this task, you need to calculate descriptive statistics and display the result. Finding descriptive statistics is an important part of A/B testing because they provide summary information about the sample. We will use this information in the future.

  1. Import the pandas.
  2. Read files.
  3. Calculate descriptive statistics.
  4. Concat the results of aggregations.
  5. Print the results.

Solution

# Import pandas library
import pandas as pd

# Read df_control .csv file
df_control = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_control.csv', delimiter=';')

# Read df_test .csv file
df_test = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_test.csv', delimiter=';')

# Calculate descriptive statistics with .agg method
control_descriptive = df_control['Impression'].agg(['count', 'mean', 'std', 'median', 'min', 'max']).round(2)
test_descriptive = df_test['Impression'].agg(['count', 'mean', 'std', 'median', 'min', 'max']).round(2)

# Concat the results of aggregations
result = pd.concat([control_descriptive, test_descriptive], axis=1)
result.columns = ['Control', 'Test']

# Print the results
print(result)

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 3
# Import pandas library
import ____ as pd

# Read df_control .csv file
df_control = pd.___('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_control.csv', delimiter=';')

# Read df_test .csv file
df_test = pd.___('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_test.csv', delimiter=';')

# Calculate descriptive statistics with .agg method
control_descriptive = df_control['Impression'].___(['count', 'mean', 'std', 'median', 'min', 'max']).round(2)
test_descriptive = df_test['Impression'].___(['count', 'mean', 'std', 'median', 'min', 'max']).round(2)

# Concat the results of aggregations
result = pd.___([control_descriptive, test_descriptive], axis=1)
result.columns = ['Control', 'Test']

# Print the results
___(result)

Demandez à l'IA

expand
ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt