Created
August 2, 2020 18:06
-
-
Save rchardptrsn/76c72572c072de48d9afb7e994595437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def clean_bls_data(df): | |
| ''' | |
| Function for cleaning BLS data into a 'tidy' vertical dataset like: | |
| State | Date | Metric | |
| Returns pandas dataframe. | |
| ''' | |
| # Melt the dataframe into vertical format. | |
| melted_df = pd.melt(df, id_vars=['Date'], | |
| value_vars=df.columns[1:], | |
| var_name='State', | |
| value_name='Pct_Unemployed' | |
| ) | |
| return melted_df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment