I am trying to have a look at the distribution of a variable with the following values..
+-------+-------+
| Value | Count |
+-------+-------+
| 0.0 | 355 |
| 1.0 | 935 |
| 2.0 | 1 |
| 3.0 | 2 |
| 4.0 | 1 |
+-------+-------+
The table continues with values up to 1000 but very sparse (total observations = 1622, almost all the observations fall in 0 or 1)
So when plotting I did:
sns.distplot(kde=True, a = df.loc[(df.class == 1)].variable_of_interest)
Which produces the following red distribution
Seaborn does not capture the initial concentration of values, but shows more "sensibility" to the rest of the values
Then I remembered pd.DataFrame.plot.kde() , so I gave it a try and it produces this plot that captures the concentration
df.loc[(df.class== 1)].variable_of_interest.plot.kde()
Important note: For those who might notice a difference in the X-axis, I did try the seaborn with xlims(-500, 1000) yet the plot remains exactly the same
Do you know why do they generate such different plots? Does it have to do with how they process data, or I am doing something wrong?
Thank you very much in advance!


