Зміст курсу
Analyzing and Visualizing Real-World Data
Analyzing and Visualizing Real-World Data
Removing and Replacing
As mentioned previously, there are two ways to perform removing or replacing operations. Since we used the .str
accessor two chapters ago, let's use a lambda function this time.
Завдання
- Define a lambda function with a single argument
x
that will:- Remove the
'$'
characters starting from the left (using the.lstrip()
method); - Replace all blank spaces (
' '
) with empty strings (''
) (using the.replace()
method); - Assign the function to the
rmv_rpl
variable.
- Remove the
- Apply the
rmv_rpl
function to the'Weekly_Sales'
column using the.apply()
method and convert it to thefloat
data type.
Завдання
- Define a lambda function with a single argument
x
that will:- Remove the
'$'
characters starting from the left (using the.lstrip()
method); - Replace all blank spaces (
' '
) with empty strings (''
) (using the.replace()
method); - Assign the function to the
rmv_rpl
variable.
- Remove the
- Apply the
rmv_rpl
function to the'Weekly_Sales'
column using the.apply()
method and convert it to thefloat
data type.
Все було зрозуміло?
Removing and Replacing
As mentioned previously, there are two ways to perform removing or replacing operations. Since we used the .str
accessor two chapters ago, let's use a lambda function this time.
Завдання
- Define a lambda function with a single argument
x
that will:- Remove the
'$'
characters starting from the left (using the.lstrip()
method); - Replace all blank spaces (
' '
) with empty strings (''
) (using the.replace()
method); - Assign the function to the
rmv_rpl
variable.
- Remove the
- Apply the
rmv_rpl
function to the'Weekly_Sales'
column using the.apply()
method and convert it to thefloat
data type.
Завдання
- Define a lambda function with a single argument
x
that will:- Remove the
'$'
characters starting from the left (using the.lstrip()
method); - Replace all blank spaces (
' '
) with empty strings (''
) (using the.replace()
method); - Assign the function to the
rmv_rpl
variable.
- Remove the
- Apply the
rmv_rpl
function to the'Weekly_Sales'
column using the.apply()
method and convert it to thefloat
data type.
Все було зрозуміло?
Removing and Replacing
As mentioned previously, there are two ways to perform removing or replacing operations. Since we used the .str
accessor two chapters ago, let's use a lambda function this time.
Завдання
- Define a lambda function with a single argument
x
that will:- Remove the
'$'
characters starting from the left (using the.lstrip()
method); - Replace all blank spaces (
' '
) with empty strings (''
) (using the.replace()
method); - Assign the function to the
rmv_rpl
variable.
- Remove the
- Apply the
rmv_rpl
function to the'Weekly_Sales'
column using the.apply()
method and convert it to thefloat
data type.
Завдання
- Define a lambda function with a single argument
x
that will:- Remove the
'$'
characters starting from the left (using the.lstrip()
method); - Replace all blank spaces (
' '
) with empty strings (''
) (using the.replace()
method); - Assign the function to the
rmv_rpl
variable.
- Remove the
- Apply the
rmv_rpl
function to the'Weekly_Sales'
column using the.apply()
method and convert it to thefloat
data type.
Все було зрозуміло?
As mentioned previously, there are two ways to perform removing or replacing operations. Since we used the .str
accessor two chapters ago, let's use a lambda function this time.
Завдання
- Define a lambda function with a single argument
x
that will:- Remove the
'$'
characters starting from the left (using the.lstrip()
method); - Replace all blank spaces (
' '
) with empty strings (''
) (using the.replace()
method); - Assign the function to the
rmv_rpl
variable.
- Remove the
- Apply the
rmv_rpl
function to the'Weekly_Sales'
column using the.apply()
method and convert it to thefloat
data type.