Skip to content Skip to sidebar Skip to footer

Seaborn Heatmap With Single Column

I have a dataframe that has an index (words) and a single column (counts) for some lyrics. I am trying to create a heatmap based on the word counts. Cuenta Que 179 La 145 Y

Solution 1:

The data is one-dimensional. The counts are already present in the one (and only) column of the dataframe. There is no meaningless way to pivot this data.

You would hence directly plot the dataframe as a heatmap.

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = pd.DataFrame({"Cuenta": [179,145,142,113,108]},
                  index=["Que", "La", "Y", "Me", "No"])

sns.heatmap(df, annot=True, fmt="g", cmap='viridis')

plt.show()

enter image description here

Post a Comment for "Seaborn Heatmap With Single Column"