Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Checking the Column Type | Preprocessing Data
Advanced Techniques in pandas

bookChecking the Column Type

If you can come across the column 'Fare', the numbers here are separated with the - sign. It looks weird, doesn't it? We used to use . as the separator, and Python can understand numbers separated only with dots. Let's check the type of this column. You can do so using the attribute .dtypes. Look at the example with the column 'Age'.

123
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/titanic3.csv', index_col = 0) print(data['Age'].dtypes)
copy

Explanation:

The .dtypes syntax is simple; you just apply it to the column or to the whole data set. In our case, the type is float64.

question-icon

Output the type of the column 'Fare'.

print(data[''].)
object

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 5. Kapitel 7

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Awesome!

Completion rate improved to 3.03

bookChecking the Column Type

Svep för att visa menyn

If you can come across the column 'Fare', the numbers here are separated with the - sign. It looks weird, doesn't it? We used to use . as the separator, and Python can understand numbers separated only with dots. Let's check the type of this column. You can do so using the attribute .dtypes. Look at the example with the column 'Age'.

123
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/titanic3.csv', index_col = 0) print(data['Age'].dtypes)
copy

Explanation:

The .dtypes syntax is simple; you just apply it to the column or to the whole data set. In our case, the type is float64.

question-icon

Output the type of the column 'Fare'.

print(data[''].)
object

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 5. Kapitel 7
some-alt