Feedback Form

Series & DataFrames in Pandas in hindi

Series & DataFrames in Pandas (Hindi Guide)

Series & DataFrames in Pandas Table of Contents (Hindi)

Series & DataFrames in Pandas in Hindi

आज के समय में Data Analysis और Data Science लगभग हर technical और non-technical field का हिस्सा बन चुका है। Python में Data को आसानी से handle करने के लिए जिस library का सबसे ज़्यादा use होता है, उसका नाम है Pandas। Pandas की पूरी foundation दो core structures पर टिकी होती है — Series और DataFrame

College exams, competitive exams और practical understanding के लिए Pandas के इन दोनों concepts को सही तरीके से समझना बहुत ज़रूरी है। इस article में हम Series & DataFrames in Pandas को बिल्कुल basic से, simple language में, real examples के साथ समझेंगे।

Pandas Series in Hindi

Pandas Series एक one-dimensional data structure होती है। इसे आप Python की list या array का advanced version मान सकते हो, जिसमें हर value के साथ एक index भी जुड़ा होता है।

Series का use तब किया जाता है जब data एक single column या single line में हो, जैसे marks की list, temperatures, prices आदि। Exam में अक्सर पूछा जाता है कि Series क्या होती है और इसका structure कैसा होता है।

What is Pandas Series

Pandas Series एक ऐसा data object है जिसमें values और index दोनों होते हैं। अगर index न दिया जाए, तो Pandas automatically numeric index create कर देता है।

Series में stored data same type का भी हो सकता है और mixed type का भी। इसी flexibility की वजह से Pandas Series real-world data के लिए बहुत useful बन जाती है।

Creating a Series in Pandas

Series बनाने के लिए Pandas की Series() function का use किया जाता है। आप list, tuple, dictionary या NumPy array से Series बना सकते हो।

नीचे simple example दिया गया है, जो exam point of view से भी important है।

import pandas as pd data = [10, 20, 30, 40] s = pd.Series(data) print(s)

इस example में Pandas automatically index 0, 1, 2, 3 assign कर देता है। अगर आप चाहो तो custom index भी दे सकते हो।

Series with Custom Index

Custom index का मतलब है कि आप values के साथ अपने अनुसार labels assign कर सकते हो। यह feature data को identify करने में बहुत मदद करता है।

marks = [75, 80, 65] subjects = ['Math', 'Science', 'English'] s = pd.Series(marks, index=subjects) print(s)

अब हर value अपने subject name से जुड़ी हुई है। Exam में इस तरह के examples बहुत common होते हैं।

Accessing Data from Series

Series से data निकालना बहुत आसान होता है। आप index number या index label दोनों का use कर सकते हो।

  • Index number से access करना
  • Index label से access करना
print(s[0]) print(s['Math'])

यह flexibility Pandas को Python list से ज्यादा powerful बनाती है। इसी वजह से data analysis में Series का use किया जाता है।

Basic Operations on Series

Pandas Series पर mathematical operations directly apply किए जा सकते हैं। यह feature exam और practical दोनों के लिए बहुत important है।

  • Addition
  • Subtraction
  • Multiplication
  • Division
s = s + 5 print(s)

इस example में Series की हर value में 5 add हो जाता है। यह operation loop के बिना possible होता है, जो Pandas को fast बनाता है।

Pandas DataFrame in Hindi

अब आते हैं Pandas के सबसे important concept पर — DataFrame। DataFrame एक two-dimensional data structure होती है, जो rows और columns में data store करती है।

अगर Series single column data है, तो DataFrame पूरी table के बराबर होता है। Real-life data जैसे student records, employee data, sales report DataFrame में ही store किए जाते हैं।

What is Pandas DataFrame

Pandas DataFrame rows और columns का collection होता है। हर column एक Series की तरह behave करता है।

Exam में अक्सर पूछा जाता है कि DataFrame और Series में क्या difference है। Short answer यह है कि Series 1D है और DataFrame 2D है।

Creating a DataFrame in Pandas

DataFrame बनाने के लिए DataFrame() function का use किया जाता है। सबसे common तरीका dictionary का use करना होता है।

data = { 'Name': ['Ravi', 'Amit', 'Neha'], 'Marks': [78, 85, 90] } df = pd.DataFrame(data) print(df)

इस example में dictionary की keys columns बन जाती हैं और values rows में convert हो जाती हैं। यह structure exam के लिए बहुत important है।

Accessing Columns in DataFrame

DataFrame से column निकालना बहुत आसान होता है। आप column name का use करके direct access कर सकते हो।

print(df['Marks'])

यह output एक Pandas Series return करता है। यानी DataFrame का हर column internally Series ही होता है।

Accessing Rows in DataFrame

Rows को access करने के लिए Pandas में loc और iloc methods use होते हैं। Exam में इन दोनों का difference भी पूछा जाता है।

  • loc – label based indexing
  • iloc – integer based indexing
print(df.loc[0]) print(df.iloc[1])

loc index label पर काम करता है और iloc position पर। यह concept समझना exam के लिए बहुत ज़रूरी है।

Why DataFrame is Important

DataFrame real-world data को handle करने के लिए सबसे suitable structure है। CSV files, Excel sheets और databases का data सीधे DataFrame में load किया जाता है।

Data cleaning, filtering, sorting और analysis जैसे tasks DataFrame के बिना practically possible नहीं हैं। इसी वजह से Pandas DataFrame data science की backbone माना जाता है।

Advanced Series Concepts in Hindi

अब जब Pandas Series का basic structure clear हो चुका है, तो आगे इसके कुछ important concepts समझना ज़रूरी है। College exams में सिर्फ definition नहीं, बल्कि Series के behavior और operations भी पूछे जाते हैं।

Series Attributes

Pandas Series के कुछ built-in attributes होते हैं, जिनसे Series की information मिलती है। ये attributes data inspection और debugging में बहुत help करते हैं।

  • index – Series का index दिखाता है
  • values – actual data values देता है
  • dtype – data type बताता है
print(s.index) print(s.values) print(s.dtype)

Exam में dtype से जुड़े questions common हैं, जैसे integer Series और float Series में difference। इसलिए attributes को ignore नहीं करना चाहिए।

Series from Dictionary

जब Series dictionary से बनाई जाती है, तो dictionary की keys index बन जाती हैं। यह feature real-world labeled data के लिए बहुत useful है।

data = {'Jan': 120, 'Feb': 150, 'Mar': 100} sales = pd.Series(data) print(sales)

अगर आप custom index देते हो, तो Pandas missing values के लिए NaN assign कर देता है। यह concept data cleaning में बहुत important होता है।

Handling Missing Values in Series

Real data में missing values आना normal है। Pandas में missing values को NaN के रूप में represent किया जाता है।

  • isnull()
  • notnull()
  • fillna()
print(sales.isnull()) sales = sales.fillna(0)

Exam point of view से fillna() method काफी important है। यह method data preprocessing में widely use होती है।

Advanced DataFrame Concepts in Hindi

अब Pandas DataFrame के advanced concepts समझते हैं, जो exams और practical दोनों में काम आते हैं। DataFrame की real power इन्हीं features से दिखती है।

DataFrame Structure (Rows & Columns)

DataFrame में rows को index और columns को labels कहा जाता है। हर cell row और column के intersection पर होता है।

इस structure की वजह से DataFrame Excel sheet जैसा feel देता है। इसी similarity के कारण students इसे जल्दी समझ पाते हैं।

Adding New Columns in DataFrame

DataFrame में नया column add करना बहुत simple है। आप existing DataFrame में directly assignment कर सकते हो।

df['Result'] = ['Pass', 'Pass', 'Pass'] print(df)

Exam में अक्सर पूछा जाता है कि DataFrame में column कैसे add करते हैं। यह direct assignment वाला तरीका सबसे आसान और popular है।

Removing Columns from DataFrame

Column remove करने के लिए drop() method use किया जाता है। axis parameter यहाँ बहुत important होता है।

df = df.drop('Result', axis=1) print(df)

axis=1 का मतलब column और axis=0 का मतलब row होता है। यह concept exam में trick question की तरह पूछा जाता है।

Adding and Removing Rows

Rows add करने के लिए आमतौर पर new DataFrame को append किया जाता है। Rows remove करने के लिए भी drop() method use होता है।

df = df.drop(0, axis=0) print(df)

Row deletion में index label use होता है, position नहीं। इसलिए students को index और position का difference clear रखना चाहिए।

Data Selection using loc and iloc

loc और iloc DataFrame selection के सबसे powerful tools हैं। इनसे specific rows और columns easily select किए जा सकते हैं।

print(df.loc[1, 'Name']) print(df.iloc[0, 1])

loc label based selection करता है और iloc integer position based। यह difference almost हर Pandas exam question में आता है।

Basic DataFrame Operations

DataFrame पर mathematical operations column-wise apply होते हैं। अगर column numeric है, तो operations automatically perform हो जाते हैं।

df['Marks'] = df['Marks'] + 5 print(df)

यह feature Pandas को traditional programming से अलग बनाता है। Loop के बिना data manipulation possible हो जाता है।

DataFrame Information and Summary

Large dataset के साथ काम करते समय DataFrame की summary देखना ज़रूरी होता है। Pandas इसके लिए built-in functions देता है।

  • head()
  • tail()
  • info()
  • describe()
print(df.head()) print(df.info()) print(df.describe())

describe() method statistics जैसे mean, min, max दिखाता है। Exam में इसे numerical summary function भी कहा जाता है।

Difference Between Series and DataFrame

Students को Series और DataFrame का difference clear होना चाहिए। नीचे table exam revision के लिए बहुत helpful है।

Series DataFrame
One-dimensional Two-dimensional
Single column data Rows and columns
Index + Values Index + Columns
Represents single data sequence Represents complete table

Exam में इस table के points short answer या long answer दोनों में लिखे जा सकते हैं। यह comparison conceptual clarity देता है।

Why Pandas is Important for Exams

Pandas सिर्फ coding tool नहीं है, बल्कि data handling का standard तरीका है। University exams में Pandas से जुड़े questions लगातार बढ़ रहे हैं।

Series और DataFrame की clear understanding future topics जैसे Data Analysis, Machine Learning और AI की base बनाती है। इसलिए इन concepts को lightly नहीं लेना चाहिए।

Real-Life Use of Series and DataFrame

Marks sheet, attendance record, sales report और survey data — ये सब practically DataFrame के form में ही process किए जाते हैं।

Series individual column analysis के लिए use होती है, जबकि DataFrame complete dataset analysis के लिए use होता है।

FAQs

Pandas Series in hindi एक one-dimensional data structure होती है, जिसमें data एक single line या single column के रूप में store होता है। Series में हर value के साथ एक index जुड़ा होता है, जिससे data को आसानी से identify और access किया जा सकता है। Exam में Series को Python list का advanced version भी कहा जाता है।

Pandas DataFrame in hindi एक two-dimensional data structure है, जिसमें data rows और columns के form में होता है। यह बिल्कुल Excel sheet या table जैसा होता है और real-world data analysis के लिए सबसे ज्यादा use किया जाता है। College exams में DataFrame को Pandas का सबसे important concept माना जाता है।

Pandas Series in hindi one-dimensional होती है और single column data represent करती है, जबकि Pandas DataFrame in hindi two-dimensional होती है और complete table को represent करती है। आसान शब्दों में, Series DataFrame का एक column होती है।

Pandas Series का use तब किया जाता है जब data single column या single sequence में हो, जैसे marks list, prices या monthly sales data। Series mathematical operations और data analysis को fast और easy बना देती है।

Pandas DataFrame in hindi exam के लिए इसलिए important है क्योंकि real-world datasets जैसे student records, attendance sheets और reports DataFrame में ही handle किए जाते हैं। loc, iloc, drop और describe जैसे methods exam questions में बार-बार पूछे जाते हैं।

हाँ, Pandas Series और DataFrame in hindi beginners के लिए easy होते हैं, अगर concepts को step-by-step और examples के साथ समझा जाए। Basic Python knowledge के बाद Pandas सीखना students के लिए काफी smooth रहता है।