Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Types consistency | Preprocessing Data: Part I
Data Manipulation using pandas
course content

Conteúdo do Curso

Data Manipulation using pandas

Data Manipulation using pandas

1. Preprocessing Data: Part I
2. Preprocessing Data: Part II
3. Grouping Data
4. Aggregating and Visualizing Data
5. Joining Data

Types consistency

One of the first steps of analyzing received data is checking the values types. If we are talking about column with age, then we expect to have there integer type; or column with salaries should be either integer or float.

Remember, to get the columns types in pandas, you should use the .dtypes attribute. Execute the code below to find out values types.

So many types... How not to get confused here? Let's see what columns have object type. To do it, we are going to use the same attribute and within square brackets set the condition. Since we received a Series object, column names will be indexes of this Series, so for convenient output we will output indexes only.

Here is the first problem. Columns 'totinch', 'morgh', 'valueh', 'grosrth', 'omphtotinch' should be considered as numerical, taking into account their specifics.

ColumnDescription
'TOTINCH'Total Household Income
'MORGH'Presence of Mortgage
'VALUEH'Value of Dwelling
'GROSRTH'Monthly Gross Rent
'OMPH'Owner's Major Payments (Monthly)

Let's find out why these columns were considered as object.

Tudo estava claro?

Seção 1. Capítulo 2
We're sorry to hear that something went wrong. What happened?
some-alt