<jupyter_start><jupyter_text>Data for Excel ExamplesDownloads unemployment rate and labor force data for the US. Exports data to Excel. This Notebook uses `fredpy`: https://www.briancjenkins.com/linearsolve/docs/build/html/index.html  Preliminaries<jupyter_code>import fredpy as fp
import matplotlib.pyplot as plt
import pandas as pd
# Load fredpy API key
fp.api_key = fp.load_api_key('fred_api_key.txt')<jupyter_output><empty_output><jupyter_text>Download data from FRED and manage<jupyter_code># Download labor market data
u = fp.series('unrate').data
u_men = fp.series('LNS14000001').data
u_women = fp.series('LNS14000002').data
lf_men = fp.series('LNS11000001').data
lf_women = fp.series('LNS11000002').data

# Concatenate data into a DataFrame
df = pd.concat([u,u_men,u_women,lf_men,lf_women],axis=1).dropna()
df.columns = ['Unemployment Rate','Unemployment Rate - Men','Unemployment Rate - Women','Labor Force - Men','Labor Force - Women']
df.index.name = 'Date'

# Export data as csv
df.to_csv('../Data/labor_force_data.csv')<jupyter_output><empty_output><jupyter_text>Plots to be produced in Excel<jupyter_code># US unemployment rate
plt.plot(u)
plt.ylabel('Percent')
plt.title('US Unemployment Rate');
# Men's and women's unemployment rates
plt.plot(u_men,label='Men')
plt.plot(u_women,'--',label='Women')
plt.ylabel('Percent')
plt.title('Unemployment Rates')
plt.legend();
# Scatter plot of men's v. women's unemployment rates
plt.scatter(u_men,u_women,s=40,alpha=0.25)
plt.xlabel('Men (Percent)')
plt.ylabel('Women (Percent)')
plt.title('Unemployment Rates');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14125, 'fraction_numerical': 0.02375, 'mean_word_length': 6.965174129353234, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '251124', 'license': 'MIT', 'n_tokens_mistral': 633, 'n_tokens_neox': 563, 'n_words': 123, 'path': 'python/Data_for_Excel_Examples.ipynb', 'repo_name': 'letsgoexploring/letsgoexploring.github.io', 'size': '1600'}