Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge | Preprocessing Data: Part I
Data Manipulation using pandas

book
Challenge

Try to apply the aquired knowledge to fix the first problematic column.

Завдання

Swipe to start coding

You are given the Statvillage dataset. You need to convert the 'totinch' column' values to float type by replacing commas by dots. Follow the next steps:

  1. Select the 'totinch' column.
  2. Apply the str accessor to the chosen column.
  3. Replace the , symbols in the column values with the ..
  4. Convert type to float.

Рішення

# Importing the library
import pandas as pd

# Reading the data
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/f2947b09-5f0d-4ad9-992f-ec0b87cd4b3f/data.csv')

# Perform a replacement and convert column type
df['totinch'] = df.totinch.str.replace(',', '.').astype(float)
# Testing
print(df.totinch)

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5
# Importing the library
import pandas as pd

# Reading the data
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/f2947b09-5f0d-4ad9-992f-ec0b87cd4b3f/data.csv')

# Perform a replacement and convert column type
df['totinch'] = ___.___.___.___(___, ___).___(___)
# Testing
print(df.totinch)

Запитати АІ

expand
ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

some-alt