Created
May 7, 2018 19:43
-
-
Save WillKoehrsen/907b143686108592ec94e83fde3584af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace the string for missing values with 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 using string matching | |
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