Skip to content

Instantly share code, notes, and snippets.

@KerryHalupka
Created July 27, 2020 10:52
Show Gist options
  • Save KerryHalupka/5a025e1af67feb90375813be673bc036 to your computer and use it in GitHub Desktop.
Save KerryHalupka/5a025e1af67feb90375813be673bc036 to your computer and use it in GitHub Desktop.
Load in and display unemployment data
import geopandas as gpd
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
import plotly.graph_objects as go
emp_df = pd.read_csv('./data/ABS_C16_G43_LGA_26072020234812892.csv') #read in the data
emp_df = emp_df[['LGA_2016', 'Labour force status', 'Region', 'Value']] #select only the columns we need
emp_df['LGA_2016'] = emp_df['LGA_2016'].astype('str') # we will join on this axis, so both dataframes need this to be the same type
emp_df = emp_df.pivot(index='LGA_2016', columns='Labour force status', values='Value').reset_index().rename_axis(None, axis=1) #pivot the dataframe to make the spatial location the index
emp_df['percent_unemployed'] = emp_df['Total Unemployed']/(emp_df['Total Unemployed']+emp_df['Total Employed']) #calculate unemployment rate
emp_df.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment