How to plot column from a dataframe

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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?





This answer may help your question :https://stackoverflow.com/questions/22483588/how-can-i-plot-separate-pandas-dataframes-as-subplots df.select_dtypes(include=["integer"]).columns.size calculates your axis size.
– Ceyhun
yesterday




df.select_dtypes(include=["integer"]).columns.size





DO you want one graph per time, subplots?..
– Joe
yesterday





I would like to have distribution of each column data in one figure
– S.Dasgupta
yesterday





Again, we don't know what df contains and what your desired output is. Please edit your question and provide a Minimal, Complete, and Verifiable example. You probably simply have to add a "plt.legend() plt.show()" after the loop to get your desired output.
– Mr. T
35 mins ago






2 Answers
2



Just try to add plot option in your loop:


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



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






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Makefile test if variable is not empty