Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Dividing into Groups | Performing One More AB Test
A/B Testing in Python

book
Dividing into Groups

Now we will divide the data into the control user group and the test user group.

Uppgift

Swipe to start coding

  1. Create the new variable df_control with the 'control' group and using the DataFrame.query() function.
  2. Create the new variable df_test with the 'test' group.
  3. Show the first row of the df_control.
  4. Show the first row of the df_test.

Lösning

# Importing the pandas
import pandas as pd

# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/1e089012-bfcf-4d61-9ac9-bb649ece39f2/abtest_with_changes.csv')

# Create the new variable df_control with the 'control' group
df_control = df.query('group == "control" ')
# Create the new variable df_test with the 'test' group
df_test = df.query('group == "test" ')

# Show the first row of the df_control
print(df_control.head(1))
# Show the first row of the df_test
print(df_test.head(1))

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 6
# Importing the pandas
import pandas as pd

# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/1e089012-bfcf-4d61-9ac9-bb649ece39f2/abtest_with_changes.csv')

# Create the new variable df_control with the 'control' group
___ = df.___('___ == "___" ')
# Create the new variable df_test with the 'test' group
___

# Show the first row of the df_control
print(___.___(1))
# Show the first row of the df_test
___

Fråga AI

expand
ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

some-alt