Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
# Define the datasets as Python list dictionaries
|
5 |
+
natural_events = [
|
6 |
+
{'location': 'Australia', 'type': 'Wildfires', 'year': 2019, 'effect': 'Temperature increase'},
|
7 |
+
{'location': 'Brazil', 'type': 'Deforestation', 'year': 2020, 'effect': 'CO2 emissions'},
|
8 |
+
{'location': 'Indonesia', 'type': 'Forest fires', 'year': 2015, 'effect': 'Air pollution'},
|
9 |
+
{'location': 'USA', 'type': 'Heat waves', 'year': 2012, 'effect': 'Crop yield reduction'},
|
10 |
+
{'location': 'Russia', 'type': 'Melting permafrost', 'year': 2016, 'effect': 'Methane emissions'}
|
11 |
+
]
|
12 |
+
|
13 |
+
population_growth = [
|
14 |
+
{'year': 2019, 'country': 'India', 'growth_rate': 1.08},
|
15 |
+
{'year': 2020, 'country': 'Nigeria', 'growth_rate': 2.58},
|
16 |
+
{'year': 2015, 'country': 'China', 'growth_rate': 0.48},
|
17 |
+
{'year': 2012, 'country': 'Ethiopia', 'growth_rate': 2.89},
|
18 |
+
{'year': 2016, 'country': 'India', 'growth_rate': 1.18}
|
19 |
+
]
|
20 |
+
|
21 |
+
# Convert the datasets to Pandas DataFrames
|
22 |
+
natural_events_df = pd.DataFrame(natural_events)
|
23 |
+
population_growth_df = pd.DataFrame(population_growth)
|
24 |
+
|
25 |
+
# Merge the two DataFrames on the year column
|
26 |
+
merged_df = pd.merge(natural_events_df, population_growth_df, on='year')
|
27 |
+
|
28 |
+
# Calculate the total population growth for each event and add it to the merged DataFrame
|
29 |
+
merged_df['total_growth'] = merged_df['growth_rate'] * 1000000
|
30 |
+
|
31 |
+
# Display the merged DataFrame in the Streamlit app
|
32 |
+
st.write(merged_df)
|