import pandas as pd
import plotly.express as px
import plotly.io as pio
pio.templates.default = "plotly_dark" # adds dark theme to better see the data
Run to view results
df_world = pd.read_csv('data/world_data.csv')
df_world.drop(columns=["Unnamed: 0"], inplace=True)
df_world
Run to view results
fig = px.scatter(data_frame = df_world,
height=675,
size_max= 60,
title = 'Bubble Size, Population, total',
labels= {
"NY.GDP.PCAP.CD": 'GDP per capita (Current US$)',
'SE.SEC.CUAT.PO.ZS': '% 25+ completed at least Post-Secondary',
'SP.POP.TOTL' : 'Population, total'
},
x="NY.GDP.PCAP.CD",
y="SE.SEC.CUAT.PO.ZS",
color="Country Name",
size='SP.POP.TOTL',
animation_frame="Year")
fig.show()
Run to view results
fig = px.scatter(data_frame = df_world,
height=600,
size_max= 60,
title = 'Bubble Size, Population, total',
labels= {
"NY.GDP.PCAP.CD": 'GDP per capita (Current US$)',
'SE.SEC.CUAT.PO.ZS': '% 25+ completed at least Post-Secondary',
'SP.POP.TOTL' : 'Population, total'
},
x="NY.GDP.PCAP.CD",
y="SE.SEC.CUAT.PO.ZS",
color="Income Group",
size='SP.POP.TOTL',
animation_frame="Year")
fig.show()
Run to view results
df_higher_ed = pd.read_csv('data/bach_data.csv')
data_m = pd.read_csv('data/mast_data.csv')
data_d = pd.read_csv('data/doc_data.csv')
df_higher_ed.drop(columns=["Unnamed: 0"], inplace=True)
# Add the masters and doctoral columns to df_higher_ed
df_higher_ed.insert(4, 'SE.TER.CUAT.MS.ZS', data_m['SE.TER.CUAT.MS.ZS'])
df_higher_ed.insert(5,'SE.TER.CUAT.DO.ZS', data_d['SE.TER.CUAT.DO.ZS'])
df_higher_ed
Run to view results
fig = px.scatter(data_frame = df_higher_ed,
height=600,
size_max=80,
title = 'Bubble Size, Population, total',
labels= {
"NY.ADJ.NNTY.PC.CD": 'Adjusted net national income per capita (current US$)',
'SE.TER.CUAT.BA.ZS': '% 25+ completed at least Bachelor\'s Degree',
'SP.POP.TOTL' : 'Population, total'
},
x='NY.ADJ.NNTY.PC.CD',
y='SE.TER.CUAT.BA.ZS',
color="Country Name",
size='SP.POP.TOTL',
animation_frame="Year")
fig.update_layout(yaxis_range = (0,df_higher_ed['SE.TER.CUAT.BA.ZS'].max()+5))
fig.show()
Run to view results
fig = px.scatter(data_frame = df_higher_ed,
height=600,
size_max=80,
title = 'Bubble Size, Population, total',
labels= {
"NY.ADJ.NNTY.PC.CD": 'Adjusted net national income per capita (current US$)',
'SE.TER.CUAT.MS.ZS': '% 25+ completed at least Master\'s Degree',
'SP.POP.TOTL' : 'Population, total'
},
x='NY.ADJ.NNTY.PC.CD',
y='SE.TER.CUAT.MS.ZS',
color="Country Name",
size='SP.POP.TOTL',
animation_frame="Year")
fig.update_layout(yaxis_range = (0,df_higher_ed['SE.TER.CUAT.MS.ZS'].max()+1))
fig.show()
Run to view results
fig = px.scatter(data_frame = df_higher_ed,
height=600,
size_max=80,
title = 'Bubble Size, Population, total',
labels= {
"NY.ADJ.NNTY.PC.CD": 'Adjusted net national income per capita (current US$)',
'SE.TER.CUAT.DO.ZS': '% 25+ completed at least Doctoral Degree',
'SP.POP.TOTL' : 'Population, total'
},
x='NY.ADJ.NNTY.PC.CD',
y='SE.TER.CUAT.DO.ZS',
color="Country Name",
size='SP.POP.TOTL',
animation_frame="Year")
fig.update_layout(yaxis_range = (0,df_higher_ed['SE.TER.CUAT.DO.ZS'].max()+.1))
fig.show()
Run to view results
fig = px.bar(data_frame = df_higher_ed,
height=600,
title= '% 25+ completed at least Bachelor\'s Degree by Country',
labels= {
"NY.ADJ.NNTY.PC.CD": 'Adjusted net national income per capita (current US$)',
'SE.TER.CUAT.BA.ZS': '% 25+ completed at least Bachelor\'s Degree',
'SP.POP.TOTL' : 'Population, total'
},
x='Country Name',
y='SE.TER.CUAT.BA.ZS',
color="Country Name",
animation_frame="Year")
fig.update_xaxes(categoryorder='total descending')
fig.show()
Run to view results
fig = px.bar(data_frame = df_higher_ed,
height=600,
title= 'Adjusted net national income per capita (current US$) by Country',
labels= {
"NY.ADJ.NNTY.PC.CD": 'Adjusted net national income per capita (current US$)',
'SE.TER.CUAT.BA.ZS': '% 25+ completed at least Bachelor\'s Degree',
'SP.POP.TOTL' : 'Population, total'
},
x='Country Name',
y='NY.ADJ.NNTY.PC.CD',
color="Country Name",
animation_frame="Year")
fig.update_xaxes(categoryorder='total descending')
fig.show()
Run to view results
fig = px.line(data_frame = df_higher_ed,
height=600,
title= 'Adjusted net national income per capita (current US$) by Country',
labels= {
"NY.ADJ.NNTY.PC.CD": 'Adjusted net national income per capita (current US$)',
'SE.TER.CUAT.BA.ZS': '% 25+ completed at least Bachelor\'s Degree',
'SP.POP.TOTL' : 'Population, total'
},
x='Year',
y='SE.TER.CUAT.BA.ZS',
color="Country Name")
fig.update_xaxes(categoryorder='total descending').update_layout(xaxis= dict(dtick = 1))
fig.show()
Run to view results