S.Dasgupta
S.Dasgupta

Reputation: 71

How to plot column from a dataframe

I am trying to plot integer columns of dataframe. I am trying by following way

for i in df:
    if df[i].dtypes == 'int64':
        df[i].plot.kde()

But it is plotting all in the same graph. I am new to it and would like to know how can I do it?

Upvotes: 2

Views: 417

Answers (2)

Bal Krishna Jha
Bal Krishna Jha

Reputation: 7206

If I understand correctly, you need :

df[(df.dtypes == 'int64').index].plot.kde(subplots=True)
#we find the columns that have int64 values and plot all columns in different plot

Using your code : all plots together using above code all plots together

Upvotes: 0

paveltr
paveltr

Reputation: 474

Just try to add plot option in your loop:

for i in df: 
    if df[i].dtypes == 'int64': 
        df[i].plot.kde()
        plt.show()

Upvotes: 1

Related Questions