Created
April 23, 2025 10:20
-
-
Save carloocchiena/99ff13bd34b57ec5fcc3328a492c7fd9 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
import matplotlib.dates as mdates | |
# 1. Riorganizza i dati: pivot con giorni sulle righe, ore sulle colonne | |
heatmap_data = df.copy() | |
heatmap_data['Date'] = heatmap_data.index.date | |
heatmap_data['Hour'] = heatmap_data.index.hour | |
pivot = heatmap_data.pivot_table(index='Date', columns='Hour', values='Value') | |
# 2. Plot della heatmap | |
plt.figure(figsize=(16, 8)) | |
sns.heatmap(pivot, cmap='YlOrRd', cbar_kws={'label': 'Value'}) | |
plt.title('Heatmap Time Series', fontsize=14) | |
plt.xlabel('Hour of Day') | |
plt.ylabel('Date') | |
plt.xticks(rotation=0) | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment