Handling Missing Values in Pandas in hindi
Handling Missing Values in Pandas in Hindi – Complete Guide
Handling Missing Values in Pandas – Table of Contents (Hindi)
- What are Missing Values in Pandas (पांडस में Missing Values क्या होते हैं)
- Detecting Missing Values in Pandas (पांडस में Missing Values को पहचानना)
- Using isnull() and notnull() in Pandas (पांडस में isnull और notnull का उपयोग)
- Removing Missing Values using dropna() (पांडस में dropna से Missing Values हटाना)
- Filling Missing Values using fillna() (पांडस में fillna से Missing Values भरना)
- Replacing Missing Values in Pandas (पांडस में Missing Values को replace करना)
- Handling Missing Values using interpolate() (पांडस में interpolate से Missing Values संभालना)
- Analyzing Missing Values in Pandas (पांडस में Missing Values का विश्लेषण)
Handling Missing Values in Pandas in Hindi
Data Analysis करते समय सबसे common problem जो हर student और developer को face करनी पड़ती है, वह है Missing Values की problem। College exams, practical files और real-world datasets — हर जगह data पूरी तरह clean नहीं होता। Pandas library इसी problem को handle करने के लिए powerful tools देती है। इस article में हम Handling Missing Values in Pandas को बिल्कुल basic level से, exam-oriented और practical तरीके से समझेंगे।
What are Missing Values in Pandas
जब किसी dataset में किसी column के अंदर कुछ rows में value मौजूद नहीं होती,
तो उसे Missing Value कहा जाता है। Pandas में ये values आमतौर पर
NaN (Not a Number) के रूप में दिखाई देती हैं।
Missing Values का main reason होता है — data collection error, user input skip करना, sensor failure या data merge करते समय mismatch। Exams में अक्सर यही पूछा जाता है कि Missing Values data analysis को कैसे affect करती हैं।
अगर Missing Values को handle नहीं किया गया, तो calculations गलत हो सकती हैं, models inaccurate हो जाते हैं और overall result unreliable हो जाता है। इसीलिए Pandas में Missing Values handling बहुत important topic है।
Detecting Missing Values in Pandas
Missing Values handle करने से पहले यह जानना जरूरी है कि dataset में कहाँ-कहाँ Missing Values मौजूद हैं। Pandas इसके लिए built-in functions provide करता है।
सबसे common method है dataset को observe करना और फिर functions का use करना जो Missing Values को identify करते हैं। Exam में direct questions आते हैं कि Missing Values detect करने के methods कौन-कौन से हैं।
Pandas Missing Values को internally NaN के रूप में treat करता है,
चाहे data type numeric हो या non-numeric।
Using isnull() and notnull() in Pandas
isnull() function check करता है कि value Missing है या नहीं।
अगर value Missing है तो result True होता है, otherwise False।
यह function mostly data inspection के लिए use होता है, ताकि हमें exact idea मिल सके कि कौन-कौन से cells empty हैं। Exams में इसे theoretical + practical दोनों रूप में पूछा जाता है।
Example समझने के लिए:
df.isnull()
इसका output एक boolean table होता है, जिसमें हर cell के लिए Missing या Not Missing status दिखता है।
इसी तरह notnull() function इसका opposite काम करता है।
अगर value present है तो True, और Missing होने पर False देता है।
df.notnull()
इन दोनों functions का use data cleaning से पहले mandatory माना जाता है, क्योंकि इससे dataset की actual condition clear हो जाती है।
Removing Missing Values using dropna()
कई situations में Missing Values को fill करना सही नहीं होता,
इसलिए उन्हें remove करना बेहतर option होता है।
Pandas में इसके लिए dropna() function use किया जाता है।
dropna() rows या columns को delete कर देता है
जहाँ Missing Values मौजूद होती हैं।
यह method तब useful होता है जब Missing data बहुत कम हो।
Basic syntax:
df.dropna()
यह by default उन rows को remove कर देता है जिनमें कम से कम एक Missing Value हो। Exam perspective से यह behaviour बहुत important है।
अगर आप columns remove करना चाहते हैं, तो axis parameter use किया जाता है।
df.dropna(axis=1)
इसके अलावा how parameter भी होता है,
जो decide करता है कि सभी values Missing हों तभी remove करना है या नहीं।
ध्यान रखने वाली बात यह है कि dropna() data loss cause कर सकता है,
इसलिए blindly use करना सही practice नहीं मानी जाती।
Filling Missing Values using fillna()
जब data loss afford नहीं किया जा सकता,
तब Missing Values को fill करना सबसे better approach होती है।
Pandas में यह काम fillna() function करता है।
fillna() Missing Values को किसी fixed value,
mean, median या mode से replace कर सकता है।
Exams में इसे सबसे ज्यादा पूछा जाता है।
Example:
df.fillna(0)
यह सभी Missing Values को 0 से replace कर देता है। Numeric datasets में यह method अक्सर use किया जाता है।
Mean से fill करने का example:
df.fillna(df.mean())
यह method data distribution को ज्यादा disturb नहीं करता, इसलिए machine learning और statistical analysis में preferred माना जाता है।
fillna() method flexibility provide करता है, जिससे different columns के लिए different strategy apply की जा सकती है।
Replacing Missing Values in Pandas
कई बार dataset में Missing Values सिर्फ NaN के रूप में नहीं होतीं,
बल्कि 0, ?, NA या empty string के रूप में भी मौजूद रहती हैं।
ऐसी situation में Handling Missing Values in Pandas के लिए
replace() method बहुत useful साबित होती है।
replace() function specific value को किसी दूसरी value से change करने की facility देता है।
Exam में अक्सर पूछा जाता है कि fillna और replace में difference क्या है।
Basic example:
df.replace(0, np.nan)
इस code का मतलब है कि जहाँ-जहाँ 0 value है,
उसे Missing Value यानी NaN में convert कर दो।
इसके बाद आप fillna या dropna apply कर सकते हैं।
Multiple values replace करने के लिए list भी use की जा सकती है।
df.replace(['NA', '?', 'missing'], np.nan)
यह approach real-world datasets में बहुत common है, क्योंकि data manually enter किया गया होता है। College practicals और projects में यह technique बहुत काम आती है।
replace() method का एक बड़ा advantage यह है कि यह targeted cleaning करने में help करता है। पूरे dataset को blindly affect नहीं करता।
Handling Missing Values using interpolate()
जब dataset numerical हो और values sequential order में हों, जैसे time series data, temperature readings या marks list, तब Missing Values को अनुमान से fill करना बेहतर होता है।
Pandas में इस purpose के लिए interpolate() method available है।
यह method existing values के आधार पर Missing Values का approximate value calculate करता है।
Simple example:
df.interpolate()
यह default linear interpolation apply करता है, जिसमें previous और next value के बीच का average fill किया जाता है।
Interpolate method खासतौर पर तब useful होता है जब data continuous nature का हो। Discrete या categorical data में इसका use avoid किया जाता है।
Exams में अक्सर पूछा जाता है कि interpolate कब use करना चाहिए। Answer simple है — जब Missing Values logical sequence को follow करती हों।
Different interpolation techniques भी available होती हैं, लेकिन college level syllabus में linear interpolation ही sufficient मानी जाती है।
Important point यह है कि interpolate method data trend को preserve करने की कोशिश करता है, जिससे analysis ज्यादा accurate बनता है।
Analyzing Missing Values in Pandas
Missing Values handle करने से पहले उनका analysis करना सबसे important step होता है। Without analysis, सही strategy decide नहीं की जा सकती।
Pandas में Missing Values analysis के लिए
isnull() और sum() combination बहुत use होता है।
df.isnull().sum()
यह code हर column में total Missing Values की count दिखाता है। Exam answer में इसे explain करना बहुत common है।
इस analysis से यह पता चलता है कि कौन सा column ज्यादा affected है और किस column को drop या fill करना better रहेगा।
अगर किसी column में बहुत ज्यादा Missing Values हों, तो उसे remove करना practical approach मानी जाती है। लेकिन अगर Missing Values कम हों, तो fill करना better option होता है।
Percentage calculation भी analysis का हिस्सा होती है।
(df.isnull().sum() / len(df)) * 100
यह formula Missing Values का percentage निकालता है, जिससे decision making आसान हो जाती है।
College exams में data-driven justification को ज्यादा marks मिलते हैं, इसलिए Missing Values analysis बहुत important topic है।
Impact of Missing Values on Data Analysis
Missing Values directly data accuracy को affect करती हैं। अगर इन्हें ignore किया जाए, तो mean, median और model prediction गलत हो सकती है।
Machine Learning algorithms Missing Values को accept नहीं करते, इसलिए Pandas में data clean करना compulsory step बन जाता है।
Exams में यह concept theoretical form में पूछा जाता है, जैसे “Why handling missing values is important?”
Best Practices for Handling Missing Values in Pandas
-
Dataset को पहले analyze करो, फिर decision लो। Without understanding, direct dropna apply मत करो।
-
Numerical data के लिए mean या interpolate method prefer करो।
-
Categorical data के लिए mode या fixed value use करो।
-
High percentage Missing Values वाले columns को remove करना better होता है।
ये best practices exams और real-world दोनों perspective से relevant हैं। Teachers practical understanding को ज्यादा importance देते हैं।
Handling Missing Values in Pandas for Exams
Exam answer लिखते समय हमेशा definition, method name और example structure follow करो। Direct code लिखना extra marks दिला सकता है।
Short answers में isnull(), dropna() और fillna()
mention करना sufficient होता है।
Long answers में analysis और impact explain करना जरूरी होता है।
अगर question practical based हो, तो proper syntax और explanation दोनों लिखो। This approach examiner पर positive impression डालती है।
इस तरह Handling Missing Values in Pandas एक complete और scoring topic बन जाता है, जो theory और practical दोनों में equal importance रखता है।
FAQs
Pandas में Missing Values उन data entries को कहते हैं जिनकी कोई value उपलब्ध नहीं होती।
इन्हें आमतौर पर NaN (Not a Number) के रूप में represent किया जाता है।
Data Analysis in hindi में Missing Values को सही तरीके से handle करना बहुत जरूरी होता है,
क्योंकि ये result की accuracy को directly affect करती हैं।
Handling Missing Values in Pandas in hindi इसलिए जरूरी है, क्योंकि अगर Missing Values को ignore कर दिया जाए, तो mean, median और model prediction गलत हो सकते हैं। Exams और real-world projects दोनों में clean data ही reliable output देता है।
Pandas में Missing Values detect करने के लिए सबसे common methods हैं
isnull() और notnull()।
ये methods boolean output देते हैं जिससे यह आसानी से पता चलता है
कि dataset में कौन-सी values missing हैं।
dropna() method Missing Values वाली rows या columns को delete कर देता है,
जबकि fillna() method Missing Values को किसी value जैसे 0, mean या median से भर देता है।
Handling Missing Values in Pandas in hindi में सही method data requirement पर depend करता है।
interpolate() method तब use किया जाता है जब dataset numerical और sequential हो, जैसे time series data। यह Missing Values को previous और next values के आधार पर estimate करता है, जिससे data trend maintain रहता है।
Exams के लिए Handling Missing Values in Pandas in hindi prepare करने के लिए
definition, importance, methods जैसे isnull(), dropna(),
fillna() और short code examples अच्छे से याद रखें।
Conceptual clarity के साथ syntax लिखना high scoring answer बनाता है।