Preprocessing Data
Imagine that last chapter you read 14 days ago. And you already have the file with all the data fixed during this period for the analyzing results of the A/B test. Now we are going to prepare all data received for the analysis.
So after rereading the task, we can make 2 points:
The test was held with the Web devices;
The test started after the 2021-01-10 Let's create a new DataFrame that will fit well with our needs.
Use
DataFrame.query()
function to create new DataFrame with options needed. Go here to learn more about thepandas
library.
Завдання
Swipe to start coding
- Import the
pandas
with thepd
alias. - Save only
'Web'
platform into the new df nameddf_platform
using theDataFrame.query()
function. - Save the information fixed only after the
'2021-01-10'
into thedf_ab
variable. - Show what is inside the
df_ab
variable.
Рішення
99
1
2
3
4
5
6
7
8
9
10
11
12
13
# Import 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.csv')
# Save only 'Web' platform into the new df
df_platform = df.query('platform == "Web" ')
# Save the information fixed only after the '2021-01-10'
df_ab = df_platform.query('date > "2021-01-10" ')
# Show the data
print(df_ab.head())
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 3. Розділ 3
99
1
2
3
4
5
6
7
8
9
10
11
12
13
# Import the pandas
import ___ as ___
# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/1e089012-bfcf-4d61-9ac9-bb649ece39f2/abtest.csv')
# Save only 'Web' platform into the new df
___ = df.query('platform == "___" ')
# Save the information fixed only after the '2021-01-10'
___ = df_platform.___('___ > "2021-01-10" ')
# Show the data
print(___.___())
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат