パンダ DataFrame.describe()

description() メソッドは、次のような統計データを計算するために使用されます。 パーセンタイル、平均 そして 標準 シリーズまたはデータフレームの数値。数値系列とオブジェクト系列の両方を分析し、混合データ型の DataFrame 列セットも分析します。

構文

 DataFrame.describe(percentiles=None, include=None, exclude=None)  

パラメーター

    パーセンタイル: これはオプションのパラメータで、0 から 1 までの数値のリストのようなデータ型です。デフォルト値は [.25, .5, .75] で、25、50、および 75 パーセンタイルを返します。 含む: これは、DataFrame を記述する際のデータ型のリストを含むオプションのパラメーターでもあります。デフォルト値は「なし」です。 除外するもの: これは、DataFrame を記述するときにデータ型のリストを除外するオプションのパラメーターでもあります。デフォルト値は「なし」です。

戻り値

シリーズとデータフレームの統計概要を返します。

例1

 import pandas as pd import numpy as np a1 = pd.Series([1, 2, 3]) a1.describe()  

出力

 count 3.0 mean 2.0 std 1.0 min 1.0 25% 1.5 50% 2.0 75% 2.5 max 3.0 dtype: float64  

例2

 import pandas as pd import numpy as np a1 = pd.Series(['p', 'q', 'q', 'r']) a1.describe()  

出力

 count 4 unique 3 top q freq 2 dtype: object  

例3

 import pandas as pd import numpy as np a1 = pd.Series([1, 2, 3]) a1.describe() a1 = pd.Series(['p', 'q', 'q', 'r']) a1.describe() info = pd.DataFrame({'categorical': pd.Categorical(['s','t','u']), 'numeric': [1, 2, 3], 'object': ['p', 'q', 'r'] }) info.describe(include=[np.number]) info.describe(include=[np.object]) info.describe(include=['category'])  

出力

 categorical count 3 unique 3 top u freq 1  

例4

 import pandas as pd import numpy as np a1 = pd.Series([1, 2, 3]) a1.describe() a1 = pd.Series(['p', 'q', 'q', 'r']) a1.describe() info = pd.DataFrame({'categorical': pd.Categorical(['s','t','u']), 'numeric': [1, 2, 3], 'object': ['p', 'q', 'r'] }) info.describe() info.describe(include='all') info.numeric.describe() info.describe(include=[np.number]) info.describe(include=[np.object]) info.describe(include=['category']) info.describe(exclude=[np.number]) info.describe(exclude=[np.object])  

出力

 categorical numeric count 3 3.0 unique 3 NaN top u NaN freq 1 NaN mean NaN 2.0 std NaN 1.0 min NaN 1.0 25% NaN 1.5 50% NaN 2.0 75% NaN 2.5 max NaN 3.0