Skip to content

Instantly share code, notes, and snippets.

@rchardptrsn
Created August 2, 2020 18:13
Show Gist options
  • Save rchardptrsn/766e18c6725b0eec98f05ae4897bf937 to your computer and use it in GitHub Desktop.
Save rchardptrsn/766e18c6725b0eec98f05ae4897bf937 to your computer and use it in GitHub Desktop.
# Convert the Date column back to string,
# find January 1st 2020,
# only keep State and percent unemployed columns
# Set index to State
jan_emp = df[df['Date'].dt.strftime(date_format='%Y-%m-%d').str.contains('2020-01-01')][['State','Pct_Unemployed']].set_index('State')
# Convert the Date column back to string,
# find June 1st 2020,
# only keep State and percent unemployed columns
# Set index to State
june_emp = df[df['Date'].dt.strftime(date_format='%Y-%m-%d').str.contains('2020-06-01')][['State','Pct_Unemployed']].set_index('State')
# Subtract the January data from the June Data
chg_emp = june_emp.subtract(jan_emp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment