3
$\begingroup$

I have a dataframe consisting of some continuous data features. I did a kde plot of the features using seaborn kdeplot functionality which gave me a plot as shown below :

Seaborn kdeplot

How do I interpret this visualization in order to check for things like skew in the data points,etc? Thanks in advance.

$\endgroup$
  • 4
    $\begingroup$ it might help to have separate plots for each variable and compute some summary statistics $\endgroup$ – oW_ Oct 21 '16 at 21:39
  • 1
    $\begingroup$ Try pandas' DataFrame.skew() and DataFrame.kurtosis() methods. This superimposed plot is more confusing than informative. $\endgroup$ – Emre Oct 21 '16 at 23:43
  • $\begingroup$ @Emre Okay but I want to visualize the skewness. Can you tell me how to do that using seaborn or pandas ? $\endgroup$ – enterML Oct 22 '16 at 17:08
  • 1
    $\begingroup$ In pandas in a notebook, df.variable.hist(). $\endgroup$ – K3---rnc Oct 23 '16 at 14:45
5
$\begingroup$

IIUC you can use [DataFrame.hist()] method:

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

matplotlib.style.use('ggplot')

df = pd.DataFrame(np.random.randint(0,10,(20,4)),columns=list('abcd'))

df.hist(alpha=0.5, figsize=(16, 10))

Result:

enter image description here

Data:

In [44]: df
Out[44]:
    a  b  c  d
0   3  0  2  5
1   8  7  6  6
2   6  4  5  7
3   4  4  0  6
4   5  6  0  2
5   0  0  4  8
6   7  6  7  4
7   7  6  6  2
8   6  5  9  4
9   6  3  6  9
10  7  9  7  6
11  9  3  5  6
12  9  4  7  0
13  2  8  8  8
14  0  8  4  7
15  1  5  2  4
16  2  6  6  4
17  0  3  8  1
18  4  1  0  4
19  4  4  6  8

In [45]: df.skew()
Out[45]:
a   -0.154849
b   -0.239881
c   -0.660912
d   -0.376480
dtype: float64

In [46]: df.describe()
Out[46]:
               a          b          c          d
count  20.000000  20.000000  20.000000  20.000000
mean    4.500000   4.600000   4.900000   5.050000
std     2.964705   2.521487   2.770142   2.502105
min     0.000000   0.000000   0.000000   0.000000
25%     2.000000   3.000000   3.500000   4.000000
50%     4.500000   4.500000   6.000000   5.500000
75%     7.000000   6.000000   7.000000   7.000000
max     9.000000   9.000000   9.000000   9.000000
|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.