File size: 1,432 Bytes
f70edb8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pandas as pd
import streamlit as st

# Define the datasets as Python list dictionaries
natural_events = [
    {'location': 'Australia', 'type': 'Wildfires', 'year': 2019, 'effect': 'Temperature increase'},
    {'location': 'Brazil', 'type': 'Deforestation', 'year': 2020, 'effect': 'CO2 emissions'},
    {'location': 'Indonesia', 'type': 'Forest fires', 'year': 2015, 'effect': 'Air pollution'},
    {'location': 'USA', 'type': 'Heat waves', 'year': 2012, 'effect': 'Crop yield reduction'},
    {'location': 'Russia', 'type': 'Melting permafrost', 'year': 2016, 'effect': 'Methane emissions'}
]

population_growth = [
    {'year': 2019, 'country': 'India', 'growth_rate': 1.08},
    {'year': 2020, 'country': 'Nigeria', 'growth_rate': 2.58},
    {'year': 2015, 'country': 'China', 'growth_rate': 0.48},
    {'year': 2012, 'country': 'Ethiopia', 'growth_rate': 2.89},
    {'year': 2016, 'country': 'India', 'growth_rate': 1.18}
]

# Convert the datasets to Pandas DataFrames
natural_events_df = pd.DataFrame(natural_events)
population_growth_df = pd.DataFrame(population_growth)

# Merge the two DataFrames on the year column
merged_df = pd.merge(natural_events_df, population_growth_df, on='year')

# Calculate the total population growth for each event and add it to the merged DataFrame
merged_df['total_growth'] = merged_df['growth_rate'] * 1000000

# Display the merged DataFrame in the Streamlit app
st.write(merged_df)