Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,8 @@ import plotly.express as px
|
|
| 13 |
import json
|
| 14 |
from difflib import get_close_matches
|
| 15 |
from xlsxwriter import Workbook
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
|
|
@@ -318,16 +320,18 @@ def fuel_norm_distribution_dashboard(root_dir, state_mapping_file, start_year=20
|
|
| 318 |
|
| 319 |
# Download button
|
| 320 |
st.markdown("### 📥 Download Filtered Data")
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
|
|
|
|
|
|
| 331 |
|
| 332 |
with tab2:
|
| 333 |
st.subheader("Emission Norm Distribution by State")
|
|
@@ -349,17 +353,18 @@ def fuel_norm_distribution_dashboard(root_dir, state_mapping_file, start_year=20
|
|
| 349 |
st.plotly_chart(fig2, use_container_width=True)
|
| 350 |
|
| 351 |
# Download button
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
|
|
|
| 363 |
with tab3:
|
| 364 |
st.subheader("Norm Emissions by Fuel Type and Year")
|
| 365 |
|
|
|
|
| 13 |
import json
|
| 14 |
from difflib import get_close_matches
|
| 15 |
from xlsxwriter import Workbook
|
| 16 |
+
import io
|
| 17 |
+
|
| 18 |
|
| 19 |
|
| 20 |
|
|
|
|
| 320 |
|
| 321 |
# Download button
|
| 322 |
st.markdown("### 📥 Download Filtered Data")
|
| 323 |
+
|
| 324 |
+
output = BytesIO()
|
| 325 |
+
with pd.ExcelWriter(output, engine='xlsxwriter') as writer:
|
| 326 |
+
filtered_df.to_excel(writer, index=False, sheet_name="Filtered Data")
|
| 327 |
+
|
| 328 |
+
st.download_button(
|
| 329 |
+
label="Download Excel",
|
| 330 |
+
data=output.getvalue(),
|
| 331 |
+
file_name="fuel_distribution_filtered.xlsx",
|
| 332 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
| 333 |
+
)formats-officedocument.spreadsheetml.sheet")
|
| 334 |
+
|
| 335 |
|
| 336 |
with tab2:
|
| 337 |
st.subheader("Emission Norm Distribution by State")
|
|
|
|
| 353 |
st.plotly_chart(fig2, use_container_width=True)
|
| 354 |
|
| 355 |
# Download button
|
| 356 |
+
st.markdown("### 📥 Download Filtered Norms Data")
|
| 357 |
+
|
| 358 |
+
norm_output = BytesIO()
|
| 359 |
+
with pd.ExcelWriter(norm_output, engine='xlsxwriter') as writer:
|
| 360 |
+
filtered_norms.to_excel(writer, index=False, sheet_name="Filtered Norms")
|
| 361 |
+
|
| 362 |
+
st.download_button(
|
| 363 |
+
label="Download Excel",
|
| 364 |
+
data=norm_output.getvalue(),
|
| 365 |
+
file_name="norm_distribution_filtered.xlsx",
|
| 366 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
| 367 |
+
)
|
| 368 |
with tab3:
|
| 369 |
st.subheader("Norm Emissions by Fuel Type and Year")
|
| 370 |
|