कोर्स परिचय

Python में Categorical Data के साथ काम करना

Kasey Jones

Research Data Scientist

"Categorical" होने का क्या मतलब है?

Categorical

  • समूहों (या श्रेणियों) की एक सीमित संख्या
  • ये श्रेणियाँ आमतौर पर तय या ज्ञात होती हैं (eye color, hair color, आदि)
  • इसे qualitative data भी कहते हैं

Numerical

  • इसे quantitative data भी कहते हैं
  • संख्यात्मक मान से व्यक्त होता है
  • आमतौर पर एक माप होता है (height, weight, IQ, आदि)
Python में Categorical Data के साथ काम करना

Ordinal बनाम nominal वैरिएबल

Ordinal

  • वे categorical वैरिएबल जिनका प्राकृतिक क्रम होता है

सर्वे जवाब अक्सर strongly disagree से strongly agree तक होते हैं. इन श्रेणियों का एक तार्किक क्रम होता है.

Nominal

  • वे categorical वैरिएबल जिन्हें प्राकृतिक क्रम में नहीं रखा जा सकता

कभी-कभी श्रेणियाँ, जैसे सूची से रंग चुनना ("Blue", "Green", "Red", "Yellow", "purple"), किसी तार्किक क्रम में नहीं होतीं.

Python में Categorical Data के साथ काम करना

हमारा पहला डेटासेट

adult.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 32561 entries, 0 to 32560
Data columns (total 15 columns):
 #   Column           Non-Null Count  Dtype 
 --  ------           --------------  ----- 
 0   Age              32561 non-null  int64 
 1   Workclass        32561 non-null  object
 2   fnlgwt           32561 non-null  int64 
 3   Education        32561 non-null  object
 4   Education Num    32561 non-null  int64 
 5   Marital Status   32561 non-null  object
...
1 https://www.kaggle.com/uciml/adult-census-income
Python में Categorical Data के साथ काम करना

describe का उपयोग

adult["Marital Status"].describe()
count                   32561
unique                      7
top        Married-civ-spouse
freq                    14976
Name: Marital Status, dtype: object
Python में Categorical Data के साथ काम करना

value_counts का उपयोग

adult["Marital Status"].value_counts()
 Married-civ-spouse       14976
 Never-married            10683
 Divorced                  4443
 Separated                 1025
 Widowed                    993
 Married-spouse-absent      418
 Married-AF-spouse           23
Name: Marital Status, dtype: int64
Python में Categorical Data के साथ काम करना

normalize के साथ value_counts

adult["Marital Status"].value_counts(normalize=True)
 Married-civ-spouse       0.459937
 Never-married            0.328092
 Divorced                 0.136452
 Separated                0.031479
 Widowed                  0.030497
 Married-spouse-absent    0.012837
 Married-AF-spouse        0.000706
Name: Marital Status, dtype: float64
Python में Categorical Data के साथ काम करना

Knowledge check

Python में Categorical Data के साथ काम करना

Preparing Video For Download...