0
$\begingroup$

I have a dataframe with X rows. For each row, I have the information of the month (value from 1 to 12) and hour (value from 1 to 24) in separate columns

I need to create a heatmap with seaborn in order to display the number of entries crossed with the month/hour.

I do not manage to do it. Any idea how should I proceed ?

$\endgroup$

1 Answer 1

2
$\begingroup$
import numpy as np
import pandas as pd
from numpy.random import RandomState
import seaborn as sns



state = RandomState(0)

df = pd.DataFrame({"month":state.randint(1,12,20),
              "hour":state.randint(1,24,20)
              })

sns.heatmap(pd.crosstab(df["month"], df["hour"]), cmap ="Reds",linewidths=1);

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.