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.
Swipe to start coding
-
Define a lambda function with a single argument
xthat 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_rplvariable.
-
-
Apply the
rmv_rplfunction to the'Weekly_Sales'column using the.apply()method and convert it to thefloatdata type.
Solução
Obrigado pelo seu feedback!
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Resumir este capítulo
Explicar o código em file
Explicar por que file não resolve a tarefa
Awesome!
Completion rate improved to 3.45
Removing and Replacing
Deslize para mostrar o menu
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.
Swipe to start coding
-
Define a lambda function with a single argument
xthat 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_rplvariable.
-
-
Apply the
rmv_rplfunction to the'Weekly_Sales'column using the.apply()method and convert it to thefloatdata type.
Solução
Obrigado pelo seu feedback!
single