iris_df = pd.DataFrame(iris.data, columns = iris.feature_names)
iris_df.columns = ["sepal_length", "sepal_width", "petal_length", "petal_width"]
iris_df.head(5)

df = iris_df[["sepal_length", "sepal_width"]]
display(df.head(5))
df = round(df)
df2 = df.groupby(["sepal_length", "sepal_width"]).size()
df3= df2.unstack()
display(df3)

# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(5, 5))

# Generate a custom diverging colormap
cmap = sns.diverging_palette(100, 10, as_cmap=True)

# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(df3, cmap=cmap, center=0,
            square=True, linewidths=.5, cbar_kws={"shrink": .5})

Posted by poterius
,