Unable to replace missing data
saurabhnitrr opened this issue · comments
Saurabh Pathak commented
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().
Will Koehrsen commented
I am not able to replicate this error. What version of pandas
and Python are you using?
Saurabh Pathak commented
Python 3.5.2 and pandas v(0.23.0)
Will Koehrsen commented
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!