Results differ between DQ and local machine?

Screen Link: Learn data science with Python and R projects

My Code:

import pandas as pd
data = pd.read_csv('AmesHousing.txt', delimiter="\t")
train = data[0:1460]
test = data[1460:]

print(train.select_dtypes(include=['int', 'float']).shape)

What I expected to happen:
I have downloaded the AmesHousing.txt dataset and attempted to run the above code using my local environment (with the Spyder IDE). I am however getting different results of the number of columns that are returned vs when I run the code in the DataQuest environment. Am I doing something blindingly obviously wrong?

I am using Pandas version 1.2.4 on my local machine.

What actually happened:

#My local output:
(1460, 11)

#Dataquest Output
(1460, 39)

Ok, I now see that DQ is using an older version of pandas. In the newer version of pandas you need to specify “int64” and “float64” as opposed to just “int” and “float” respectively. Even better would be just use df.select_dtypes(include=“number”).

2 Likes