 Replacing Characters
Replacing Characters
Just as we removed characters, there are also two ways to perform replacements: either by using the .str accessor or by using a lambda function. Since we are only performing the replacement for one column, let's use the first approach.
Swipe to start coding
- 
Replace the commas with dots in the 'CPI'column. Follow these steps:- Select the 'CPI'column;
- Use the .straccessor;
- Replace the ','symbols with'.'using the.replace()method;
- Convert the values to floattype;
- Assign the obtained result to the 'CPI'column.
 
- Select the 
- 
Display the first row of the dfdataframe and data types of thedfdataframe.
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Сумаризуйте цей розділ
Пояснити код у file
Пояснити, чому file не вирішує завдання
Awesome!
Completion rate improved to 3.45 Replacing Characters
Replacing Characters
Свайпніть щоб показати меню
Just as we removed characters, there are also two ways to perform replacements: either by using the .str accessor or by using a lambda function. Since we are only performing the replacement for one column, let's use the first approach.
Swipe to start coding
- 
Replace the commas with dots in the 'CPI'column. Follow these steps:- Select the 'CPI'column;
- Use the .straccessor;
- Replace the ','symbols with'.'using the.replace()method;
- Convert the values to floattype;
- Assign the obtained result to the 'CPI'column.
 
- Select the 
- 
Display the first row of the dfdataframe and data types of thedfdataframe.
Рішення
Дякуємо за ваш відгук!
single