I have solar radiation records from a weather station (1 record every 10'), as a pandas dataframe. I want to generate a heatmap plot of the complete dataset, where on the x-axis, I have the hour of the day (0-24), on the y axis each day of the year and the color gives the value.
My dataframe is called "solar". I used
solar_grouped = solar.groupby(pd.Grouper(freq='D'))
to group the data by day, but then I am unable to access each day, and I have no clue how to start for plotting the heatmap
CodePudding user response:
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
x = data.groupby(["Day",'Hour'])["Target_Col"].mean()
mean_ = round(x.mean(),2)
x = x.unstack().fillna(mean_)
plt.figure(figsize=(len(x.columns),len(x.index)))
sns.heatmap(data=x, annot=True)
