Skip to content

Instantly share code, notes, and snippets.

@fasiha
Last active January 12, 2024 08:05
Show Gist options
  • Save fasiha/5b0072f2d5c279e8464b81479e61b13d to your computer and use it in GitHub Desktop.
Save fasiha/5b0072f2d5c279e8464b81479e61b13d to your computer and use it in GitHub Desktop.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
plt.ion()
# URL for the data
url = "https://data.bls.gov/timeseries/JTS510000000000000LDL"
# Creating a date range from 2001 to 2023
dates = pd.date_range(start='2001-01-01', end='2023-11-01', freq='MS')
# Creating a mock-up data for 'Value'
import numpy as np
values = np.array([
44, 43, 23, 55, 47, 52, 46, 48, 57, 55, 62, 54, 52, 31, 42, 62, 44, 47, 45,
41, 37, 40, 45, 38, 42, 47, 45, 36, 47, 47, 41, 42, 43, 37, 33, 43, 32, 35,
40, 33, 37, 44, 24, 25, 49, 31, 18, 19, 26, 15, 27, 21, 29, 21, 38, 38, 32,
26, 41, 28, 25, 48, 28, 41, 21, 23, 24, 28, 23, 31, 34, 33, 40, 45, 28, 26,
32, 26, 35, 43, 27, 21, 19, 22, 25, 22, 35, 28, 19, 37, 18, 20, 40, 52, 43,
42, 37, 38, 39, 47, 41, 37, 46, 34, 28, 40, 33, 45, 36, 23, 24, 23, 34, 24,
27, 26, 29, 22, 23, 30, 24, 21, 29, 20, 26, 25, 24, 20, 21, 21, 22, 26, 24,
29, 28, 26, 26, 20, 20, 38, 24, 18, 20, 20, 22, 24, 12, 26, 29, 42, 45, 58,
44, 43, 23, 43, 40, 55, 47, 39, 30, 28, 47, 26, 33, 40, 39, 32, 31, 27, 30,
36, 27, 30, 26, 26, 25, 30, 31, 22, 25, 30, 24, 31, 33, 26, 29, 27, 14, 20,
27, 21, 26, 25, 31, 28, 39, 38, 26, 32, 42, 41, 26, 43, 40, 37, 36, 35, 32,
37, 29, 36, 36, 23, 28, 39, 35, 38, 36, 37, 38, 29, 58, 38, 34, 37, 34, 51,
27, 33, 191, 169, 36, 35, 27, 29, 21, 32, 32, 30, 25, 27, 27, 23, 26, 31,
29, 30, 42, 31, 33, 36, 61, 11, 19, 28, 30, 32, 37, 59, 31, 47, 46, 46, 48,
49, 49, 14, 41, 26, 46, 28, 24, 15, 32
])
# Creating the DataFrame
data = pd.DataFrame({'Date': dates, 'Value': values})
# Preparing the data for the heatmap
data['Year'] = data['Date'].dt.year
data['Month'] = data['Date'].dt.month
heatmap_data = data.pivot('Year', 'Month', 'Value')
# Plotting the heatmap
plt.figure(figsize=(12, 10))
sns.heatmap(heatmap_data,
cmap="YlGnBu",
annot=True,
fmt=".0f",
vmin=10,
vmax=60)
plt.title(
"Information industry, layoffs and discharges: thousands (BLS: JTS510000000000000LDL)"
)
plt.tight_layout()
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fasiha
Copy link
Author

fasiha commented Jan 12, 2024

layoffs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment