सदस्यता बाधाएँ

Python में डेटा क्लीनिंग

Adel Nehme

Content Developer @DataCamp

 

 

 

 

 

 

 

अध्याय 2 - टेक्स्ट और कैटेगोरिकल डेटा समस्याएँ

Python में डेटा क्लीनिंग

श्रेणियाँ और सदस्यता बाधाएँ

पूर्व-परिभाषित सीमित श्रेणियाँ

डेटा का प्रकार उदाहरण मान सांख्यिक निरूपण
वैवाहिक स्थिति unmarried, married 0,1
घर की आय श्रेणी 0-20K, 20-40K, ... 0,1, ..
ऋण स्थिति default,payed,no_loan 0,1,2

 

Marriage status सिर्फ unmarried _या_ married हो सकती है

Python में डेटा क्लीनिंग

ये समस्याएँ क्यों हो सकती हैं?

categorical_issues

Python में डेटा क्लीनिंग

हम इन समस्याओं को कैसे संभालें?

    categories

Python में डेटा क्लीनिंग

एक उदाहरण

# Read study data and print it
study_data = pd.read_csv('study.csv')
study_data
      name   birthday blood_type
1     Beth 2019-10-20         B-
2 Ignatius 2020-07-08         A-
3     Paul 2019-08-12         O+
4    Helen 2019-03-17         O-
5 Jennifer 2019-12-17         Z+
6  Kennedy 2020-04-27         A+
7    Keith 2019-04-19        AB+
# Correct possible blood types
categories
  blood_type
1         O-
2         O+
3         A-
4         A+
5         B+
6         B-
7        AB+
8        AB-
Python में डेटा क्लीनिंग

एक उदाहरण

# Read study data and print it
study_data = pd.read_csv('study.csv')
study_data
      name   birthday blood_type
1     Beth 2019-10-20         B-
2 Ignatius 2020-07-08         A-
3     Paul 2019-08-12         O+
4    Helen 2019-03-17         O-
5 Jennifer 2019-12-17         Z+  <--
6  Kennedy 2020-04-27         A+
7    Keith 2019-04-19        AB+
# Correct possible blood types
categories
  blood_type
1         O-
2         O+
3         A-
4         A+
5         B+
6         B-
7        AB+
8        AB-
Python में डेटा क्लीनिंग

जॉइन पर एक टिप्पणी

Python में डेटा क्लीनिंग

ब्लड टाइप्स पर लेफ्ट एंटी जॉइन

Python में डेटा क्लीनिंग

ब्लड टाइप्स पर इनर जॉइन

Python में डेटा क्लीनिंग

असंगत श्रेणियाँ ढूँढना

inconsistent_categories = set(study_data['blood_type']).difference(categories['blood_type'])
print(inconsistent_categories)
{'Z+'}
# Get and print rows with inconsistent categories
inconsistent_rows = study_data['blood_type'].isin(inconsistent_categories)

study_data[inconsistent_rows]
      name   birthday blood_type
5 Jennifer 2019-12-17         Z+
Python में डेटा क्लीनिंग

असंगत श्रेणियाँ हटाना

inconsistent_categories = set(study_data['blood_type']).difference(categories['blood_type'])
inconsistent_rows = study_data['blood_type'].isin(inconsistent_categories)
inconsistent_data = study_data[inconsistent_rows]

# Drop inconsistent categories and get consistent data only consistent_data = study_data[~inconsistent_rows]
      name   birthday blood_type
1     Beth 2019-10-20         B-
2 Ignatius 2020-07-08         A-
3     Paul 2019-08-12         O+
4    Helen 2019-03-17         O-
...    ...      ...          ...
Python में डेटा क्लीनिंग

अभ्यास करते हैं!

Python में डेटा क्लीनिंग

Preparing Video For Download...