# pandas DataFrame describe for categorical and numeric data
# based on dtypes(object or numeric), check the summary info separately
import pandas as pd
import numpy as np
iris = pd.read_csv(r'H:\python\data\iris.csv')
# data info with each column dtype
iris.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 150 entries, 0 to 149
Data columns (total 5 columns):
sepal _length 150 non-null float64
sepal_width 150 non-null float64
petal_length 150 non-null float64
petal_width 150 non-null float64
iris_class 150 non-null object
dtypes: float64(4), object(1)
memory usage: 7.0+ KB
def check_qual(indata):
return indata.select_dtypes(include = ['object']).describe()
def check_quant(indata):
return indata.select_dtypes(exclude = ['object']).describe()
check_qual(iris)
|
iris_class |
count |
150 |
unique |
3 |
top |
Iris-setosa |
freq |
50 |
|
sepal _length |
sepal_width |
petal_length |
petal_width |
count |
150.000000 |
150.000000 |
150.000000 |
150.000000 |
mean |
5.843333 |
3.054000 |
3.758667 |
1.198667 |
std |
0.828066 |
0.433594 |
1.764420 |
0.763161 |
min |
4.300000 |
2.000000 |
1.000000 |
0.100000 |
25% |
5.100000 |
2.800000 |
1.600000 |
0.300000 |
50% |
5.800000 |
3.000000 |
4.350000 |
1.300000 |
75% |
6.400000 |
3.300000 |
5.100000 |
1.800000 |
max |
7.900000 |
4.400000 |
6.900000 |
2.500000 |