Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,14 +37,13 @@ st.markdown("""
|
|
| 37 |
@st.cache_data
|
| 38 |
def load_data():
|
| 39 |
try:
|
| 40 |
-
# Load data
|
| 41 |
-
df = pd.read_csv("Frontier AI DC Emissions - Frontier Timeline.csv")
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
# Removes hidden spaces (e.g. "Power (MW) " -> "Power (MW)")
|
| 45 |
df.columns = df.columns.str.strip()
|
| 46 |
|
| 47 |
-
# Validation: Check if columns exist
|
| 48 |
required_cols = ['Power (MW)', 'Carbon Intensity', 'Annual Million tCO2']
|
| 49 |
missing = [c for c in required_cols if c not in df.columns]
|
| 50 |
if missing:
|
|
@@ -65,8 +64,9 @@ def load_data():
|
|
| 65 |
df['Carbon Intensity'] = df['Carbon Intensity'].apply(clean_numeric)
|
| 66 |
df['Annual Million tCO2'] = df['Annual Million tCO2'].apply(clean_numeric)
|
| 67 |
|
| 68 |
-
# ---
|
| 69 |
# Formula: MW * 8760 hours * (Intensity kg/MWh / 1000 to get tonnes) / 1,000,000 to get Million Tonnes
|
|
|
|
| 70 |
df['Calculated_Mt'] = (df['Power (MW)'] * 8760 * df['Carbon Intensity']) / 1e9
|
| 71 |
|
| 72 |
# Use the Reported number, but normalize it (Handle the 13,093 vs 13.1 issue)
|
|
@@ -74,7 +74,6 @@ def load_data():
|
|
| 74 |
df['Emissions_Mt'] = df['Annual Million tCO2'].apply(lambda x: x / 1000 if x > 100 else x)
|
| 75 |
|
| 76 |
# --- Geocoding (Manual Overrides for missing Lat/Long) ---
|
| 77 |
-
# Add coordinates for known projects if missing
|
| 78 |
overrides = {
|
| 79 |
'Fermi': [35.344, -101.373], # Amarillo, TX
|
| 80 |
'Crane': [40.154, -76.725], # Three Mile Island
|
|
|
|
| 37 |
@st.cache_data
|
| 38 |
def load_data():
|
| 39 |
try:
|
| 40 |
+
# Load data, skipping the first empty row (header=1 means Row 2 is the header)
|
| 41 |
+
df = pd.read_csv("Frontier AI DC Emissions - Frontier Timeline.csv", header=1)
|
| 42 |
|
| 43 |
+
# Sanitize Headers (removes hidden spaces)
|
|
|
|
| 44 |
df.columns = df.columns.str.strip()
|
| 45 |
|
| 46 |
+
# Validation: Check if columns exist
|
| 47 |
required_cols = ['Power (MW)', 'Carbon Intensity', 'Annual Million tCO2']
|
| 48 |
missing = [c for c in required_cols if c not in df.columns]
|
| 49 |
if missing:
|
|
|
|
| 64 |
df['Carbon Intensity'] = df['Carbon Intensity'].apply(clean_numeric)
|
| 65 |
df['Annual Million tCO2'] = df['Annual Million tCO2'].apply(clean_numeric)
|
| 66 |
|
| 67 |
+
# --- MATH CHECK (Verification) ---
|
| 68 |
# Formula: MW * 8760 hours * (Intensity kg/MWh / 1000 to get tonnes) / 1,000,000 to get Million Tonnes
|
| 69 |
+
# We calculate this to double-check the CSV's reported numbers
|
| 70 |
df['Calculated_Mt'] = (df['Power (MW)'] * 8760 * df['Carbon Intensity']) / 1e9
|
| 71 |
|
| 72 |
# Use the Reported number, but normalize it (Handle the 13,093 vs 13.1 issue)
|
|
|
|
| 74 |
df['Emissions_Mt'] = df['Annual Million tCO2'].apply(lambda x: x / 1000 if x > 100 else x)
|
| 75 |
|
| 76 |
# --- Geocoding (Manual Overrides for missing Lat/Long) ---
|
|
|
|
| 77 |
overrides = {
|
| 78 |
'Fermi': [35.344, -101.373], # Amarillo, TX
|
| 79 |
'Crane': [40.154, -76.725], # Three Mile Island
|