Skip to content

Instantly share code, notes, and snippets.

@WillKoehrsen
Created May 16, 2018 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WillKoehrsen/5803cedcbf6f697bd9bdbfcbed759cda to your computer and use it in GitHub Desktop.
Save WillKoehrsen/5803cedcbf6f697bd9bdbfcbed759cda to your computer and use it in GitHub Desktop.
# 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment