WillKoehrsen / machine-learning-project-walkthrough

An implementation of a complete machine learning solution in Python on a real-world dataset. This project is meant to demonstrate how all the steps of a machine learning pipeline come together to solve a problem!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to replace missing data

saurabhnitrr opened this issue · comments

while running the following snippet of code given here :

# Replace all occurrences of Not Available with numpy not a number
data = data.replace({'Not Available': np.nan})

# Iterate through the columns
for col in list(data.columns):
    # Select columns that should be numeric
    if ('ft²' in col or 'kBtu' in col or 'Metric Tons CO2e' in col or 'kWh' in 
        col or 'therms' in col or 'gal' in col or 'Score' in col):
        # Convert the data type to float
        data[col] = data[col].astype(float)

Following error occurs:

TypeError: Type aliases cannot be used with isinstance().

I am not able to replicate this error. What version of pandas and Python are you using?

Python 3.5.2 and pandas v(0.23.0)

I am using Python == 3.6.4 and pandas == 0.23.0 and have no issues. I would try searching for your issue online or editing the code until it works!