Dividing into Groups
Now we will divide the data into the control user group and the test user group.
Uppgift
Swipe to start coding
- Create the new variable
df_control
with the'control'
group and using theDataFrame.query()
function. - Create the new variable
df_test
with the'test'
group. - Show the first row of the
df_control
. - Show the first row of the
df_test
.
Lösning
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 6
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal