syllogismos syllogismos - 1 year ago 121
Python Question

How to plot several categorical features in a single plot in python?

I have a pandas data frame with each row of data containing an id and several binary data that has only two options 0 or 1.

id, feat1, feat2, feat3, feat4

aa, 0, 1, 1, 0

ab, 1, 0, 1, 0

ac, 0, 0, 1, 0

and etc

I want to be able to visualise this with id on y-axis, and all features on x axis.. with a dot representing 1 and no dot representing 0.. almost like the above dataframe but in plot form

Answer Source

You may consider the heatmap:

import seaborn as sns
ax = sns.heatmap(df.set_index('id'), annot = True)

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download