Complete study material based on syllabus
In any organization, vast amounts of data are generated daily. Storing this data in simple files leads to redundancy, inconsistency, and slow retrieval. Answering even a simple question like "which customers bought a specific product last month" becomes extremely difficult without a structured query system. The problem is: how to efficiently store, manage, and retrieve interrelated data with accuracy, speed, and security. This gave rise to Database Management Systems (DBMS) and SQL – the standard language to communicate with relational databases.
Database : An organized collection of structured data, generally stored electronically.
Example: a school database containing students, teachers, and courses.
DBMS : Software that manages databases (e.g., MySQL, Oracle, PostgreSQL).
RDBMS : A DBMS based on the relational model; data is stored in tables (relations) with
rows (tuples) and columns (attributes).
SQL (Structured Query Language) : A standard language for querying and manipulating
relational databases. It allows creating tables, inserting data, retrieving filtered results, updating
records, and more.
Consider a student database table Students:
+----+----------+------+--------+ | ID | Name | Age | City | +----+----------+------+--------+ | 1 | Aman | 17 | Delhi | | 2 | Bhavna | 16 | Mumbai | | 3 | Chirag | 18 | Delhi | +----+----------+------+--------+
Create table :
CREATE TABLE Students (ID INT PRIMARY KEY, Name VARCHAR(30), Age INT, City VARCHAR(20));
Insert data : INSERT INTO Students VALUES (1, 'Aman', 17, 'Delhi');
Query : SELECT Name, Age FROM Students WHERE City='Delhi' ORDER BY Age; →
returns Aman (17) and Chirag (18).
SQL Command Categories :
Important SQL Clauses & Operators :
SQL
|
+----+----+----+----+
| | | | |
DDL DML DQL TCL DCL
| | | | |
CREATE INSERT SELECT COMMIT GRANT
ALTER UPDATE ROLLBACK REVOKE
DROP DELETE SAVEPOINT
TRUNCATE
Fig: Categories of SQL commands with common examples.
SQL is the backbone of data handling in modern applications. A strong grasp of database concepts – tables, keys, constraints – and SQL commands from Class XI (DDL, DML, SELECT with clauses, aggregate functions) empowers students to build efficient, secure, and scalable data‑driven systems. Regular practice with queries is essential to mastering the language and moving to advanced topics like joins and sub‑queries.
Employee with columns: EmpID (primary key), EmpName
(not null), Department, Salary.किसी भी संगठन में हर दिन भारी मात्रा में डेटा उत्पन्न होता है। इस डेटा को सामान्य फ़ाइलों में रखने से अतिरेक, असंगति और धीमी पुनर्प्राप्ति होती है। "पिछले महीने किन ग्राहकों ने कोई विशेष उत्पाद खरीदा" जैसे सरल प्रश्न का उत्तर देना बिना किसी संरचित क्वेरी प्रणाली के अत्यंत कठिन हो जाता है। समस्या है: परस्पर संबंधित डेटा को सटीकता, गति और सुरक्षा के साथ कुशलतापूर्वक कैसे संग्रहीत, प्रबंधित और पुनर्प्राप्त किया जाए। इसी ने डेटाबेस प्रबंधन प्रणाली (DBMS) और SQL को जन्म दिया – रिलेशनल डेटाबेस से संवाद करने की मानक भाषा।
डेटाबेस : संरचित डेटा का एक संगठित संग्रह, आमतौर पर इलेक्ट्रॉनिक रूप में। उदाहरण: एक
स्कूल डेटाबेस जिसमें छात्र, शिक्षक और पाठ्यक्रम हों।
DBMS : डेटाबेस को प्रबंधित करने वाला सॉफ़्टवेयर (जैसे MySQL, Oracle, PostgreSQL)।
RDBMS : रिलेशनल मॉडल पर आधारित DBMS; डेटा तालिकाओं (संबंधों) में पंक्तियों (टपल्स) और
स्तंभों (गुणों) के रूप में संग्रहीत होता है।
SQL (स्ट्रक्चर्ड क्वेरी लैंग्वेज) : रिलेशनल डेटाबेस से पूछताछ और हेरफेर करने की मानक
भाषा। यह तालिका बनाने, डेटा डालने, फ़िल्टर किए गए परिणाम प्राप्त करने, रिकॉर्ड अपडेट करने आदि की अनुमति
देती है।
एक छात्र डेटाबेस तालिका Students पर विचार करें:
+----+----------+------+--------+ | ID | नाम | आयु | शहर | +----+----------+------+--------+ | 1 | अमन | 17 | दिल्ली | | 2 | भावना | 16 | मुंबई | | 3 | चिराग | 18 | दिल्ली | +----+----------+------+--------+
तालिका बनाएँ :
CREATE TABLE Students (ID INT PRIMARY KEY, नाम VARCHAR(30), आयु INT, शहर VARCHAR(20));
डेटा डालें : INSERT INTO Students VALUES (1, 'अमन', 17, 'दिल्ली');
क्वेरी : SELECT नाम, आयु FROM Students WHERE शहर='दिल्ली' ORDER BY आयु; →
अमन (17) और चिराग (18) लौटाता है।
SQL कमांड श्रेणियाँ :
महत्वपूर्ण SQL खंड और ऑपरेटर :
SQL
|
+----+----+----+----+
| | | | |
DDL DML DQL TCL DCL
| | | | |
CREATE INSERT SELECT COMMIT GRANT
ALTER UPDATE ROLLBACK REVOKE
DROP DELETE SAVEPOINT
TRUNCATE
चित्र: सामान्य उदाहरणों के साथ SQL कमांड की श्रेणियाँ।
SQL आधुनिक अनुप्रयोगों में डेटा प्रबंधन की रीढ़ है। डेटाबेस अवधारणाओं – तालिकाएँ, कुंजियाँ, प्रतिबंध – और कक्षा 11 के SQL कमांड्स (DDL, DML, SELECT विभिन्न खंडों, समुच्चय फलनों के साथ) की मजबूत समझ छात्रों को कुशल, सुरक्षित और स्केलेबल डेटा‑संचालित सिस्टम बनाने में सक्षम बनाती है। क्वेरीज़ का नियमित अभ्यास भाषा में निपुणता और जॉइन व सब‑क्वेरी जैसे उन्नत विषयों की ओर बढ़ने के लिए आवश्यक है।
Employee नामक तालिका बनाने का SQL कमांड लिखिए जिसके स्तंभ हों: EmpID (प्राथमिक कुंजी),
EmpName (नॉट नल), विभाग, वेतन।Database tables often store numbers that need to be transformed before display or further analysis – for example computing squares, rounding off financial figures, or finding remainders for categorization. Without built‑in mathematical functions, such tasks would require fetching raw data and processing it in an application layer, slowing down reports and increasing complexity. The core problem is: how to perform essential arithmetic operations directly inside SQL queries with accuracy and minimal performance overhead. MySQL addresses this with a rich set of numeric functions.
POWER(X, Y) : Returns the value of X raised to the power Y (i.e., XY). Both
arguments are numeric. Equivalent to the POW(X,Y) function.
ROUND(X, D) : Rounds the number X to D decimal places. If D is omitted, it defaults to
0 (rounds to integer). D can be negative to round digits left of the decimal point.
MOD(X, Y) : Returns the remainder of X divided by Y. It works like X % Y.
The result has the same sign as the dividend X.
POWER() :
SELECT POWER(2, 3); -- 8 SELECT POWER(5, 0); -- 1 SELECT POWER(16, 0.5); -- 4 (square root) SELECT POWER(2, -2); -- 0.25
ROUND() :
SELECT ROUND(15.678, 2); -- 15.68 SELECT ROUND(15.678, 1); -- 15.7 SELECT ROUND(15.678, 0); -- 16 SELECT ROUND(15.678, -1); -- 20 SELECT ROUND(2.5); -- 3 (rounds away from zero)
MOD() :
SELECT MOD(10, 3); -- 1 SELECT MOD(15, 4); -- 3 SELECT MOD(100, 10); -- 0 SELECT MOD(-10, 3); -- -1 (same sign as dividend) SELECT MOD(10, -3); -- 1
These three belong to MySQL’s Numeric / Mathematical Functions category. Other commonly used functions in the same family include:
MOD(X, Y) = X - Y * FLOOR(X/Y).Function | Syntax | Example | Result ---------------|-----------------|---------------------|------- POWER (POW) | POWER(X, Y) | POWER(2, 4) | 16 ROUND | ROUND(X [, D]) | ROUND(3.14159, 2) | 3.14 MOD | MOD(X, Y) / X%Y | MOD(17, 5) | 2
POWER, ROUND, and MOD are essential building blocks for numerical data processing in MySQL. They allow developers to embed powerful arithmetic directly into queries, improving performance and readability while reducing external code. Understanding their precise behavior – especially rounding rules and remainder sign – helps avoid subtle bugs and ensures accurate results in reports and applications.
Products with column price, write a query to round each
price to the nearest integer.amount = 12345.6789, what will ROUND(amount, -2) return? Verify with a
query.ROUND() and TRUNCATE() with an example.
MOD(-25, 4) and MOD(25, -4)? Why?डेटाबेस तालिकाओं में अक्सर ऐसी संख्याएँ होती हैं जिन्हें दिखाने या विश्लेषण से पहले बदलने की ज़रूरत होती है – जैसे वर्ग निकालना, वित्तीय आँकड़ों को गोल करना, या श्रेणीकरण के लिए शेषफल ज्ञात करना। अंतर्निहित गणित फलनों के बिना, ऐसे कार्यों के लिए कच्चा डेटा खींचकर एप्लिकेशन स्तर पर संसाधित करना पड़ता, जिससे रिपोर्ट धीमी होती और जटिलता बढ़ती। मुख्य समस्या है: SQL क्वेरी के अंदर ही आवश्यक अंकगणितीय संक्रियाएँ सटीकता और न्यूनतम प्रदर्शन भार के साथ कैसे की जाएँ। MySQL इसके लिए समृद्ध संख्यात्मक फलन प्रदान करता है।
POWER(X, Y) : X की घात Y पर मान लौटाता है (अर्थात XY)। दोनों तर्क संख्यात्मक
हैं। यह POW(X,Y) के समान है।
ROUND(X, D) : संख्या X को D दशमलव स्थानों तक गोल करता है। यदि D छोड़ दिया जाए, तो 0
मानता है (पूर्णांक तक गोल)। D ऋणात्मक हो सकता है, दशमलव बिंदु के बाईं ओर गोल करने के लिए।
MOD(X, Y) : X को Y से भाग देने पर शेषफल देता है। इसे X % Y भी लिख सकते
हैं। परिणाम का चिह्न भाज्य X के अनुसार होता है।
POWER() :
SELECT POWER(2, 3); -- 8 SELECT POWER(5, 0); -- 1 SELECT POWER(16, 0.5); -- 4 (वर्गमूल) SELECT POWER(2, -2); -- 0.25
ROUND() :
SELECT ROUND(15.678, 2); -- 15.68 SELECT ROUND(15.678, 1); -- 15.7 SELECT ROUND(15.678, 0); -- 16 SELECT ROUND(15.678, -1); -- 20 SELECT ROUND(2.5); -- 3 (शून्य से दूर गोल)
MOD() :
SELECT MOD(10, 3); -- 1 SELECT MOD(15, 4); -- 3 SELECT MOD(100, 10); -- 0 SELECT MOD(-10, 3); -- -1 (भाज्य के चिह्न के समान) SELECT MOD(10, -3); -- 1
ये तीनों MySQL के संख्यात्मक / गणितीय फलन श्रेणी में आते हैं। इसी परिवार के अन्य सामान्यतः उपयोग होने वाले फलन:
MOD(X, Y) = X - Y * FLOOR(X/Y)।फलन | सिंटैक्स | उदाहरण | परिणाम --------------|-----------------|--------------------|------- POWER (POW) | POWER(X, Y) | POWER(2, 4) | 16 ROUND | ROUND(X [, D]) | ROUND(3.14159, 2) | 3.14 MOD | MOD(X, Y) / X%Y | MOD(17, 5) | 2
POWER, ROUND और MOD, MySQL में संख्यात्मक डेटा प्रसंस्करण के लिए आवश्यक आधारभूत खंड हैं। ये डेवलपर्स को सीधे क्वेरी में शक्तिशाली अंकगणित जोड़ने की अनुमति देते हैं, जिससे प्रदर्शन और पठनीयता में सुधार होता है और बाहरी कोड कम होता है। इनके सटीक व्यवहार – विशेषकर गोल करने के नियम और शेषफल चिह्न – को समझना सूक्ष्म बगों से बचने और रिपोर्ट व अनुप्रयोगों में सटीक परिणाम सुनिश्चित करने में मदद करता है।
Products में price स्तंभ है। हर मूल्य को निकटतम पूर्णांक तक गोल
करने की क्वेरी लिखिए।amount = 12345.6789 हो, तो ROUND(amount, -2) क्या लौटाएगा? क्वेरी से
पुष्टि करें।ROUND() और TRUNCATE() में अंतर स्पष्ट कीजिए।MOD(-25, 4) और MOD(25, -4) का परिणाम क्या होगा? क्यों?In real‑world databases, string data often arrives messy – extra spaces, mixed cases, or embedded information that needs extraction. Performing these cleaning and extraction tasks in the application layer would mean transferring large result sets and writing extra code. The core problem is: how to transform and examine text directly inside SQL queries, efficiently and without moving data out of the database. MySQL provides a rich set of built‑in string functions that solve exactly this.
UCASE(str) / UPPER(str) : Converts all characters in str to uppercase.
LCASE(str) / LOWER(str) : Converts all characters in str to lowercase.
MID(str, pos, len) / SUBSTRING(str, pos, len) / SUBSTR(str, pos, len) : Returns a
substring of str starting at position pos (1‑based) for len
characters. If len is omitted, returns from pos to end of string.
LENGTH(str) : Returns the length of the string in bytes. (For character count, use
CHAR_LENGTH()).
LEFT(str, len) : Returns the leftmost len characters of
str.
RIGHT(str, len) : Returns the rightmost len characters of
str.
INSTR(str, substr) : Returns the position (1‑based) of the first occurrence of
substr in str. Returns 0 if not found.
LTRIM(str) : Removes leading spaces from str.
RTRIM(str) : Removes trailing spaces from str.
TRIM( [remstr FROM] str ) : Removes both leading and trailing spaces by default.
Optionally, remstr can be specified along with LEADING, TRAILING, or BOTH keywords.
All examples use SELECT. Consider a sample string ' Hello World! ' and a
table Students with column name.
SELECT UPPER('hello'); -- 'HELLO'
SELECT LOWER('HELLO'); -- 'hello'
SELECT SUBSTRING('MySQL', 2, 3); -- 'ySQ'
SELECT MID('Computer', 4, 3); -- 'put'
SELECT LENGTH('Data'); -- 4 (bytes)
SELECT LEFT('Informatics', 5); -- 'Infor'
SELECT RIGHT('Informatics', 6); -- 'matics'
SELECT INSTR('database', 'tab'); -- 4
SELECT LTRIM(' space'); -- 'space'
SELECT RTRIM('space '); -- 'space'
SELECT TRIM(' hello '); -- 'hello'
SELECT TRIM(LEADING '0' FROM '00123');-- '123'
SELECT TRIM(TRAILING 'x' FROM 'abcx');-- 'abc'
SELECT TRIM(BOTH '*' FROM '**hi**'); -- 'hi'
WHERE UPPER(name) = 'A') often prevents index usage, causing full table scans.
LENGTH() returns byte length, not
character count; using it on UTF‑8 strings gives unexpected results.
Function | Example | Output
----------------------|-----------------------------|---------
UPPER('abc') | SELECT UPPER('abc') | ABC
LOWER('XYZ') | SELECT LOWER('XYZ') | xyz
SUBSTRING('MySQL',2,3)| SELECT SUBSTR('MySQL',2,3) | ySQ
LEFT('Hello',3) | SELECT LEFT('Hello',3) | Hel
RIGHT('Hello',3) | SELECT RIGHT('Hello',3) | llo
LENGTH('abc') | SELECT LENGTH('abc') | 3
INSTR('find','in') | SELECT INSTR('find','in') | 2
LTRIM(' x') | SELECT LTRIM(' x') | x
RTRIM('x ') | SELECT RTRIM('x ') | x
TRIM(' a b ') | SELECT TRIM(' a b ') | a b
MySQL’s text functions provide a powerful toolkit for cleaning, formatting, and extracting information directly within SQL queries. Mastering UPPER/LOWER for case uniformity, SUBSTRING/LEFT/RIGHT for extraction, LENGTH for validation, INSTR for location, and TRIM/RTRIM/LTRIM for cleaning ensures efficient data handling without extra programming layers. Understanding their characteristics – especially byte vs. character length and indexing implications – is key to writing robust and fast queries.
students.users table.code column that stores values like '000123'?
Write the query using TRIM.products table to uppercase using UPDATE and UPPER.LENGTH('Hello') returns 5 but for a UTF‑8 string it may return more than
the character count.वास्तविक दुनिया के डेटाबेस में स्ट्रिंग डेटा अक्सर गन्दा आता है – अतिरिक्त रिक्त स्थान, मिश्रित केस, या एम्बेडेड जानकारी जिसे निकालने की ज़रूरत होती है। एप्लिकेशन लेयर में इन सफाई और निष्कर्षण कार्यों को करने का मतलब होगा बड़े परिणाम सेट स्थानांतरित करना और अतिरिक्त कोड लिखना। मूल समस्या है: SQL क्वेरी के अंदर ही टेक्स्ट को रूपांतरित और जाँच कैसे करें, कुशलता से और डेटा को डेटाबेस से बाहर ले जाए बिना। MySQL अंतर्निहित स्ट्रिंग फंक्शन का एक समृद्ध सेट प्रदान करता है जो ठीक यही हल करता है।
UCASE(str) / UPPER(str) : स्ट्रिंग str के सभी अक्षरों को बड़े अक्षरों
(अपरकेस) में बदलता है।
LCASE(str) / LOWER(str) : स्ट्रिंग str के सभी अक्षरों को छोटे अक्षरों
(लोअरकेस) में बदलता है।
MID(str, pos, len) / SUBSTRING(str, pos, len) / SUBSTR(str, pos, len) : स्ट्रिंग
str का एक भाग (सबस्ट्रिंग) लौटाता है जो pos स्थान से शुरू होता है और
len अक्षरों तक जाता है। स्थान 1‑आधारित है। यदि len छोड़ दें तो अंत तक लौटाता
है।
LENGTH(str) : स्ट्रिंग की लंबाई बाइट्स में लौटाता है। (अक्षर गिनती के लिए
CHAR_LENGTH() का प्रयोग करें।)
LEFT(str, len) : str के बाएँ से len अक्षर लौटाता है।
RIGHT(str, len) : str के दाएँ से len अक्षर लौटाता है।
INSTR(str, substr) : str में substr की पहली उपस्थिति का स्थान
(1‑आधारित) लौटाता है। यदि नहीं मिलता तो 0 देता है।
LTRIM(str) : str के आरंभ के रिक्त स्थान हटाता है।
RTRIM(str) : str के अंत के रिक्त स्थान हटाता है।
TRIM( [remstr FROM] str ) : डिफ़ॉल्ट रूप से दोनों ओर के रिक्त स्थान हटाता है। वैकल्पिक
रूप से remstr और LEADING, TRAILING, BOTH निर्दिष्ट कर सकते हैं।
सभी उदाहरण SELECT का उपयोग करते हैं। मान लीजिए एक स्ट्रिंग ' Hello World! '
और एक तालिका Students जिसमें name कॉलम है।
SELECT UPPER('hello'); -- 'HELLO'
SELECT LOWER('HELLO'); -- 'hello'
SELECT SUBSTRING('MySQL', 2, 3); -- 'ySQ'
SELECT MID('Computer', 4, 3); -- 'put'
SELECT LENGTH('Data'); -- 4 (बाइट्स)
SELECT LEFT('Informatics', 5); -- 'Infor'
SELECT RIGHT('Informatics', 6); -- 'matics'
SELECT INSTR('database', 'tab'); -- 4
SELECT LTRIM(' space'); -- 'space'
SELECT RTRIM('space '); -- 'space'
SELECT TRIM(' hello '); -- 'hello'
SELECT TRIM(LEADING '0' FROM '00123');-- '123'
SELECT TRIM(TRAILING 'x' FROM 'abcx');-- 'abc'
SELECT TRIM(BOTH '*' FROM '**hi**'); -- 'hi'
WHERE UPPER(name) = 'A') से इंडेक्स उपयोग अक्सर रुक जाता है, फुल टेबल स्कैन होता है।
LENGTH() बाइट लंबाई देता है, अक्षर गिनती
नहीं; UTF‑8 स्ट्रिंग्स पर अप्रत्याशित परिणाम।
फंक्शन | उदाहरण | परिणाम
----------------------|-----------------------------|---------
UPPER('abc') | SELECT UPPER('abc') | ABC
LOWER('XYZ') | SELECT LOWER('XYZ') | xyz
SUBSTRING('MySQL',2,3)| SELECT SUBSTR('MySQL',2,3) | ySQ
LEFT('Hello',3) | SELECT LEFT('Hello',3) | Hel
RIGHT('Hello',3) | SELECT RIGHT('Hello',3) | llo
LENGTH('abc') | SELECT LENGTH('abc') | 3
INSTR('find','in') | SELECT INSTR('find','in') | 2
LTRIM(' x') | SELECT LTRIM(' x') | x
RTRIM('x ') | SELECT RTRIM('x ') | x
TRIM(' a b ') | SELECT TRIM(' a b ') | a b
MySQL के टेक्स्ट फंक्शन SQL क्वेरी के भीतर सीधे डेटा की सफाई, फ़ॉर्मेटिंग और जानकारी निकालने का शक्तिशाली टूलकिट प्रदान करते हैं। UPPER/LOWER से केस एकरूपता, SUBSTRING/LEFT/RIGHT से निष्कर्षण, LENGTH से मान्यता, INSTR से स्थान निर्धारण, और TRIM/RTRIM/LTRIM से सफाई में निपुणता बिना अतिरिक्त प्रोग्रामिंग लेयर के कुशल डेटा हैंडलिंग सुनिश्चित करती है। इनकी विशेषताओं – विशेषकर बाइट बनाम अक्षर लंबाई और इंडेक्सिंग निहितार्थ – को समझना मजबूत और तेज़ क्वेरी लिखने की कुंजी है।
students तालिका से हर छात्र के नाम के पहले 4 अक्षर दिखाने की क्वेरी लिखिए।users तालिका के ईमेल पते के अंतिम 3 अक्षर दिखाइए।code '000123' जैसे मान रखता है, उससे अग्रणी शून्य कैसे हटाएँगे? TRIM का उपयोग
करके क्वेरी लिखें।products तालिका के सभी उत्पाद नाम अपरकेस में बदलिए।LENGTH('Hello') 5 क्यों देता है लेकिन UTF‑8 स्ट्रिंग के लिए यह अक्षर गिनती से
अधिक मान दे सकता है।Many database applications need to record, filter, and display dates and times – order dates, birth dates, login timestamps. Raw date-time data stored in columns is not directly useful for reporting; we often need to extract only the year, get the name of the month, or insert the current timestamp. Doing this in application code after fetching data adds complexity. The problem is: how to efficiently retrieve and format date/time components directly inside SQL queries. MySQL's date functions solve this elegantly.
NOW() : Returns the current date and time as YYYY-MM-DD HH:MM:SS. The
value is constant within a single statement.
DATE(expr) : Extracts the date part (without time) from a datetime expression. Result
format: YYYY-MM-DD.
MONTH(date) : Returns the month number (1–12) from a date.
MONTHNAME(date) : Returns the full month name (e.g., 'January', 'February') for a given
date.
YEAR(date) : Returns the year (a four‑digit number) from a date.
DAY(date) / DAYOFMONTH(date) : Returns the day of the month (1–31).
DAYNAME(date) : Returns the weekday name (e.g., 'Monday', 'Tuesday') for a date.
Assume a table Orders with a order_date column of type DATE or
DATETIME.
SELECT NOW(); -- 2026-07-17 15:30:45 (example output)
SELECT DATE(NOW()); -- 2026-07-17
SELECT DATE('2026-07-17 09:15:00'); -- 2026-07-17
SELECT MONTH('2026-07-17'); -- 7
SELECT MONTHNAME('2026-07-17'); -- July
SELECT YEAR('2026-07-17'); -- 2026
SELECT DAY('2026-07-17'); -- 17
SELECT DAYNAME('2026-07-17'); -- Friday
WHERE YEAR(order_date) = 2025 quickly filters by
year.YEAR(date_col)) prevents index usage, causing full table scans.
Function | Example | Output
----------------|--------------------------------|-----------
NOW() | SELECT NOW() | 2026-07-17 15:30:45
DATE(expr) | SELECT DATE('2026-07-17 09:15')| 2026-07-17
MONTH(date) | SELECT MONTH('2026-07-17') | 7
MONTHNAME(date) | SELECT MONTHNAME('2026-07-17') | July
YEAR(date) | SELECT YEAR('2026-07-17') | 2026
DAY(date) | SELECT DAY('2026-07-17') | 17
DAYNAME(date) | SELECT DAYNAME('2026-07-17') | Friday
MySQL's date functions are indispensable for any application that deals with temporal data. NOW() captures the current instant; DATE() strips time; YEAR(), MONTH(), DAY() extract numerical components; MONTHNAME() and DAYNAME() provide readable names. Using these functions wisely inside queries avoids extra application logic and keeps data processing close to the storage layer. However, always be mindful of indexing implications when using functions in WHERE clauses and design your tables accordingly.
employees with column hire_date, list all employees hired in
the year 2020 using the YEAR() function.sales table with a
sale_date column? (Hint: use DAYNAME()).WHERE MONTH(order_date) = 7 may be slow on a large table and suggest an
alternative.अधिकांश डेटाबेस अनुप्रयोगों को दिनांक और समय रिकॉर्ड करने, फ़िल्टर करने और प्रदर्शित करने की आवश्यकता होती है – ऑर्डर की तारीख, जन्म तिथि, लॉगिन टाइमस्टैम्प। कॉलम में संग्रहीत कच्चा दिनांक-समय डेटा रिपोर्टिंग के लिए सीधे उपयोगी नहीं है; हमें अक्सर केवल वर्ष निकालना, महीने का नाम प्राप्त करना, या वर्तमान टाइमस्टैम्प डालना होता है। डेटा खींचने के बाद एप्लिकेशन कोड में ऐसा करने से जटिलता बढ़ती है। समस्या है: SQL क्वेरी के अंदर ही दिनांक/समय घटकों को कुशलतापूर्वक कैसे प्राप्त और स्वरूपित किया जाए। MySQL के दिनांक फंक्शन इसे सुरुचिपूर्ण ढंग से हल करते हैं।
NOW() : वर्तमान दिनांक और समय YYYY-MM-DD HH:MM:SS प्रारूप में लौटाता है।
एकल स्टेटमेंट के भीतर मान स्थिर रहता है।
DATE(expr) : किसी डेटटाइम एक्सप्रेशन से केवल दिनांक भाग (बिना समय) निकालता है। परिणाम
प्रारूप: YYYY-MM-DD।
MONTH(date) : दिनांक से महीने की संख्या (1–12) लौटाता है।
MONTHNAME(date) : दिए गए दिनांक के लिए महीने का पूरा नाम (जैसे, 'January', 'February')
लौटाता है।
YEAR(date) : दिनांक से वर्ष (चार अंकों की संख्या) लौटाता है।
DAY(date) / DAYOFMONTH(date) : महीने का दिन (1–31) लौटाता है।
DAYNAME(date) : दिनांक के लिए सप्ताह के दिन का नाम (जैसे, 'Monday', 'Tuesday') लौटाता
है।
मान लीजिए एक तालिका Orders जिसमें order_date कॉलम DATE या
DATETIME प्रकार का है।
SELECT NOW(); -- 2026-07-17 15:30:45 (उदाहरण आउटपुट)
SELECT DATE(NOW()); -- 2026-07-17
SELECT DATE('2026-07-17 09:15:00'); -- 2026-07-17
SELECT MONTH('2026-07-17'); -- 7
SELECT MONTHNAME('2026-07-17'); -- July
SELECT YEAR('2026-07-17'); -- 2026
SELECT DAY('2026-07-17'); -- 17
SELECT DAYNAME('2026-07-17'); -- Friday
WHERE YEAR(order_date) = 2025 तुरंत वर्ष के अनुसार
फ़िल्टर करता है।YEAR(date_col)) से इंडेक्स उपयोग बाधित होता है, फुल टेबल स्कैन होता है।
फंक्शन | उदाहरण | आउटपुट
--------------|--------------------------------|-----------
NOW() | SELECT NOW() | 2026-07-17 15:30:45
DATE(expr) | SELECT DATE('2026-07-17 09:15')| 2026-07-17
MONTH(date) | SELECT MONTH('2026-07-17') | 7
MONTHNAME(date)| SELECT MONTHNAME('2026-07-17')| July
YEAR(date) | SELECT YEAR('2026-07-17') | 2026
DAY(date) | SELECT DAY('2026-07-17') | 17
DAYNAME(date) | SELECT DAYNAME('2026-07-17') | Friday
MySQL के दिनांक फंक्शन किसी भी ऐसे अनुप्रयोग के लिए अनिवार्य हैं जो अस्थायी डेटा से निपटता है। NOW() वर्तमान क्षण कैप्चर करता है; DATE() समय हटाता है; YEAR(), MONTH(), DAY() संख्यात्मक घटक निकालते हैं; MONTHNAME() और DAYNAME() पठनीय नाम प्रदान करते हैं। क्वेरी के भीतर इन फंक्शनों का बुद्धिमानी से उपयोग अतिरिक्त एप्लिकेशन तर्क से बचाता है और डेटा प्रसंस्करण को भंडारण परत के पास रखता है। हालाँकि, WHERE खंडों में फंक्शन का उपयोग करते समय इंडेक्सिंग प्रभावों के प्रति सचेत रहें और तदनुसार तालिका डिज़ाइन करें।
employees तालिका में hire_date कॉलम है। YEAR() फंक्शन का उपयोग करके वर्ष
2020 में नियुक्त सभी कर्मचारी सूचीबद्ध करें।sales तालिका में sale_date कॉलम है। सभी शुक्रवार (Friday) के रिकॉर्ड कैसे
सूचीबद्ध करेंगे? (संकेत: DAYNAME() का उपयोग करें।)WHERE MONTH(order_date) = 7 धीमा क्यों हो सकता है और एक
वैकल्पिक सुझाव दीजिए।In a database table, we often need summary information – for example, the highest salary in a company, total sales for the month, average marks of a class, or the number of employees in each department. Without built‑in aggregate functions, retrieving such summaries would require fetching all rows and performing calculations in the application, wasting network bandwidth, memory, and time. The core problem is: how to efficiently compute single‑value summaries from multiple rows directly inside SQL queries. MySQL’s aggregate functions – MAX(), MIN(), AVG(), SUM(), COUNT() – solve exactly this.
Aggregate Functions : Functions that take a collection of rows and return a single
result.
They are most often used with the SELECT statement and can be combined with the
GROUP BY clause to produce
per‑group summaries.
MAX(expression) : Returns the maximum value of the expression in the selected rows.
MIN(expression) : Returns the minimum value.
AVG(expression) : Returns the average (arithmetic mean) of all values; ignores
NULL values.
SUM(expression) : Returns the total sum of all values; ignores NULL.
COUNT(expression) : Returns the number of rows where the expression is not
NULL.
COUNT(*) : Counts every row in the result set, including rows with NULL
values and duplicate rows.
Assume a table Employees with columns id, name,
salary, dept.
-- Sample data SELECT * FROM Employees; +----+--------+--------+------+ | id | name | salary | dept | +----+--------+--------+------+ | 1 | Alice | 50000 | IT | | 2 | Bob | 55000 | HR | | 3 | Carol | 60000 | IT | | 4 | Dave | NULL | HR | +----+--------+--------+------+ -- Aggregate queries SELECT MAX(salary) FROM Employees; -- 60000 SELECT MIN(salary) FROM Employees; -- 50000 SELECT AVG(salary) FROM Employees; -- 55000.0000 (ignores NULL) SELECT SUM(salary) FROM Employees; -- 165000 (50000+55000+60000) SELECT COUNT(salary) FROM Employees; -- 3 (ignores NULL) SELECT COUNT(*) FROM Employees; -- 4 (counts all rows) SELECT COUNT(DISTINCT dept) FROM Employees; -- 2
WHERE clause;
they require HAVING, which can confuse beginners.COUNT(DISTINCT col) to count unique
values only.
Function | Syntax | Example on salary set {50,55,60} | Output
----------|-----------------|-----------------------------------|-------
MAX() | MAX(salary) | MAX(salary) | 60
MIN() | MIN(salary) | MIN(salary) | 50
AVG() | AVG(salary) | AVG(salary) | 55.0000
SUM() | SUM(salary) | SUM(salary) | 165
COUNT() | COUNT(salary) | COUNT(salary) | 3
COUNT(*) | COUNT(*) | COUNT(*) | 4 (if one NULL row present)
Aggregate functions are the backbone of data analysis in SQL. MAX(), MIN(), AVG(), SUM(), and COUNT() let you transform rows of raw data into meaningful summaries with a single line. COUNT(*) provides the all‑inclusive row count, while COUNT(column) respects NULLs. Mastering these functions, together with GROUP BY and HAVING, enables efficient report generation and decision‑making directly from the database. Always be mindful of NULL handling and the distinction between WHERE and HAVING when building aggregate queries.
employees table.
sales table with columns product, quantity,
price, calculate total revenue (quantity * price) using SUM().COUNT(*) and COUNT(column_name) with an
example.employees table using COUNT().WHERE AVG(salary) > 50000? How would you correct this query?
NULL marks, what does AVG(marks) return? Does it
differ from the true average of all students?डेटाबेस तालिका में हमें अक्सर सारांश जानकारी की आवश्यकता होती है – जैसे, कंपनी में सबसे अधिक वेतन, महीने की कुल बिक्री, कक्षा के औसत अंक, या प्रत्येक विभाग में कर्मचारियों की संख्या। अंतर्निहित एग्रीगेट फंक्शन के बिना, ऐसे सारांश प्राप्त करने के लिए सभी पंक्तियाँ खींचकर एप्लिकेशन में गणना करनी पड़ती, जिससे नेटवर्क बैंडविड्थ, मेमोरी और समय बर्बाद होता। मुख्य समस्या है: SQL क्वेरी के अंदर ही अनेक पंक्तियों से एकल‑मान सारांश कुशलतापूर्वक कैसे प्राप्त करें। MySQL के एग्रीगेट फंक्शन – MAX(), MIN(), AVG(), SUM(), COUNT() – ठीक यही हल करते हैं।
एग्रीगेट फंक्शन : ऐसे फंक्शन जो पंक्तियों के संग्रह पर काम करके एकल परिणाम लौटाते हैं।
ये अक्सर SELECT स्टेटमेंट के साथ उपयोग होते हैं और GROUP BY खंड के साथ जोड़कर
प्रति‑समूह सारांश तैयार करते हैं।
MAX(expression) : चयनित पंक्तियों में अभिव्यक्ति का अधिकतम मान लौटाता है।
MIN(expression) : न्यूनतम मान लौटाता है।
AVG(expression) : सभी मानों का औसत (अंकगणित माध्य) देता है; NULL मानों को
अनदेखा करता है।
SUM(expression) : सभी मानों का कुल योग देता है; NULL अनदेखा करता है।
COUNT(expression) : उन पंक्तियों की संख्या लौटाता है जहाँ अभिव्यक्ति NULL
नहीं है।
COUNT(*) : परिणाम सेट की हर पंक्ति गिनता है, जिसमें NULL वाली और डुप्लिकेट
पंक्तियाँ भी शामिल हैं।
मान लीजिए एक तालिका Employees जिसमें id, name,
salary, dept कॉलम हैं।
-- नमूना डेटा SELECT * FROM Employees; +----+--------+--------+------+ | id | name | salary | dept | +----+--------+--------+------+ | 1 | Alice | 50000 | IT | | 2 | Bob | 55000 | HR | | 3 | Carol | 60000 | IT | | 4 | Dave | NULL | HR | +----+--------+--------+------+ -- एग्रीगेट क्वेरीज़ SELECT MAX(salary) FROM Employees; -- 60000 SELECT MIN(salary) FROM Employees; -- 50000 SELECT AVG(salary) FROM Employees; -- 55000.0000 (NULL अनदेखा) SELECT SUM(salary) FROM Employees; -- 165000 (50000+55000+60000) SELECT COUNT(salary) FROM Employees; -- 3 (NULL अनदेखा) SELECT COUNT(*) FROM Employees; -- 4 (सभी पंक्तियाँ गिनता है) SELECT COUNT(DISTINCT dept) FROM Employees; -- 2
WHERE खंड में नहीं लगा सकते;
HAVING चाहिए, जो नए सीखने वालों को भ्रमित कर सकता है।COUNT(DISTINCT col) जैसे प्रयोग से केवल अद्वितीय मान
गिन सकते हैं।
फंक्शन | सिंटैक्स | वेतन सेट {50,55,60} पर उदाहरण | आउटपुट
----------|-----------------|--------------------------------|-------
MAX() | MAX(salary) | MAX(salary) | 60
MIN() | MIN(salary) | MIN(salary) | 50
AVG() | AVG(salary) | AVG(salary) | 55.0000
SUM() | SUM(salary) | SUM(salary) | 165
COUNT() | COUNT(salary) | COUNT(salary) | 3
COUNT(*) | COUNT(*) | COUNT(*) | 4 (यदि एक NULL पंक्ति मौजूद हो)
एग्रीगेट फंक्शन SQL में डेटा विश्लेषण की रीढ़ हैं। MAX(), MIN(), AVG(), SUM() और COUNT() आपको कच्चे डेटा की पंक्तियों को एक ही पंक्ति में सार्थक सारांश में बदलने देते हैं। COUNT(*) सभी पंक्तियों की समावेशी गणना देता है, जबकि COUNT(column) NULL का सम्मान करता है। इन फंक्शनों को GROUP BY और HAVING के साथ मिलाकर कुशल रिपोर्ट निर्माण और निर्णय लेना सीधे डेटाबेस से संभव होता है। एग्रीगेट क्वेरी बनाते समय NULL हैंडलिंग और WHERE तथा HAVING के अंतर को हमेशा ध्यान में रखें।
employees तालिका से अधिकतम, न्यूनतम और औसत वेतन खोजने की क्वेरी लिखिए।sales तालिका में product, quantity, price कॉलम
हैं। SUM() का उपयोग करके कुल राजस्व (quantity * price) की गणना करें।COUNT(*) और COUNT(column_name) में अंतर उदाहरण सहित समझाइए।employees तालिका से विभिन्न विभागों (distinct departments) की संख्या COUNT() से ज्ञात
कीजिए।WHERE AVG(salary) > 50000 क्यों नहीं लिख सकते? इस क्वेरी को कैसे सही करेंगे?NULL अंक हैं, तो AVG(marks) क्या लौटाता है? क्या यह सभी
छात्रों के सही औसत से भिन्न है?
When you run a simple SELECT query, the database returns rows in an undefined order, and
all rows are mixed together.
But in real life, we often need to group rows based on a common value (like all
students from the same city),
filter those groups based on aggregate conditions (like only cities with more than 3
students),
and finally sort the output meaningfully (like alphabetically by city name).
Without GROUP BY, HAVING, and ORDER BY, such tasks would require
exporting data to another tool or writing complex application code.
The core problem is: how to organise, summarise, and sort data directly inside SQL
queries.
GROUP BY : A clause that groups rows that have the same values in specified columns. It
is almost always used with aggregate functions (COUNT, SUM, AVG, MAX, MIN) to produce summary results
per group.
HAVING : A clause that filters groups created by GROUP BY. It works on
aggregate results, unlike WHERE which filters individual rows before grouping.
HAVING comes after GROUP BY.
ORDER BY : A clause that sorts the final result set in ascending (ASC) or
descending (DESC) order based on one or more columns. It can be used with or without
GROUP BY.
Consider a table Orders with columns: order_id, customer,
city, amount.
-- Sample data SELECT * FROM Orders; +----------+----------+--------+--------+ | order_id | customer | city | amount | +----------+----------+--------+--------+ | 1 | Alice | Delhi | 500 | | 2 | Bob | Mumbai | 700 | | 3 | Carol | Delhi | 300 | | 4 | Dave | Mumbai | 200 | | 5 | Eve | Delhi | 400 | | 6 | Frank | Pune | 600 | +----------+----------+--------+--------+ -- Group by city, get total amount and count SELECT city, SUM(amount) AS total_amt, COUNT(*) AS no_of_orders FROM Orders GROUP BY city; +--------+-----------+---------------+ | city | total_amt | no_of_orders | +--------+-----------+---------------+ | Delhi | 1200 | 3 | | Mumbai | 900 | 2 | | Pune | 600 | 1 | +--------+-----------+---------------+ -- Filter groups: only cities with more than 1 order SELECT city, SUM(amount) AS total_amt FROM Orders GROUP BY city HAVING COUNT(*) > 1; +--------+-----------+ | city | total_amt | +--------+-----------+ | Delhi | 1200 | | Mumbai | 900 | +--------+-----------+ -- Sort by total amount descending SELECT city, SUM(amount) AS total_amt FROM Orders GROUP BY city ORDER BY total_amt DESC; +--------+-----------+ | city | total_amt | +--------+-----------+ | Delhi | 1200 | | Mumbai | 900 | | Pune | 600 | +--------+-----------+
ORDER BY col1 ASC, col2 DESC – sorts
by col1 first, then col2.ORDER BY 2 DESC sorts by the 2nd column in
the SELECT list.HAVING city = 'Delhi' is allowed but better placed in WHERE.GROUP BY col1, col2 creates groups for
each unique combination.
+----------------+
| FROM | (read tables)
+-------+--------+
|
v
+----------------+
| WHERE | (filter rows)
+-------+--------+
|
v
+----------------+
| GROUP BY | (form groups)
+-------+--------+
|
v
+----------------+
| HAVING | (filter groups)
+-------+--------+
|
v
+----------------+
| SELECT | (choose columns, compute aggregates)
+-------+--------+
|
v
+----------------+
| ORDER BY | (sort final result)
+-------+--------+
|
v
[ final output ]
This diagram shows the logical order in which SQL clauses are processed. Understanding this helps avoid common mistakes.
GROUP BY, HAVING, and ORDER BY are essential tools for turning raw data into meaningful, sorted summaries. GROUP BY collapses rows into categories; HAVING filters those categories based on aggregate values; ORDER BY arranges the final output. Mastering these clauses enables you to write powerful analytical queries directly in SQL, reducing the need for external data manipulation. Always keep in mind the execution order, the difference between WHERE and HAVING, and the column restrictions that come with grouping.
students table
containing name and city.results table
(subject, marks). Sort the result by maximum marks descending.WHERE and HAVING? Give an example that
shows both used together.employees table
(dept, salary). Include only departments with a total salary above 200,000
and order the result by total salary descending.GROUP BY clause? Justify your answer with an example.
जब आप साधारण SELECT क्वेरी चलाते हैं, तो डेटाबेस पंक्तियाँ अनिश्चित क्रम में लौटाता है और
सभी पंक्तियाँ एक साथ मिल जाती हैं।
लेकिन वास्तविक जीवन में हमें अक्सर एक समान मान के आधार पर पंक्तियों को समूहित (group)
करना होता है (जैसे एक ही शहर के सभी छात्र),
फिर उन समूहों को एग्रीगेट शर्तों पर फ़िल्टर करना (जैसे केवल वे शहर जहाँ 3 से अधिक छात्र
हैं),
और अंत में आउटपुट को सार्थक रूप से क्रमबद्ध (sort) करना (जैसे शहर के नाम से वर्णमाला
क्रम में)।
GROUP BY, HAVING, और ORDER BY के बिना, ऐसे कार्यों के लिए डेटा को
किसी अन्य उपकरण में निर्यात करना या जटिल एप्लिकेशन कोड लिखना पड़ता।
मुख्य समस्या है: SQL क्वेरी के अंदर ही डेटा को कैसे व्यवस्थित, सारांशित और क्रमबद्ध किया
जाए।
GROUP BY : एक खंड जो निर्दिष्ट स्तंभों में समान मान वाली पंक्तियों को समूह में रखता है।
यह लगभग हमेशा एग्रीगेट फंक्शनों (COUNT, SUM, AVG, MAX, MIN) के साथ उपयोग होता है ताकि प्रति समूह सारांश
परिणाम प्राप्त किए जा सकें।
HAVING : एक खंड जो GROUP BY द्वारा बनाए गए समूहों को फ़िल्टर करता है। यह
एग्रीगेट परिणामों पर कार्य करता है, जबकि WHERE समूहीकरण से पहले अलग-अलग पंक्तियों को
फ़िल्टर करता है। HAVING, GROUP BY के बाद आता है।
ORDER BY : एक खंड जो अंतिम परिणाम सेट को एक या अधिक स्तंभों के अनुसार आरोही
(ASC) या अवरोही (DESC) क्रम में क्रमबद्ध करता है। इसका उपयोग
GROUP BY के साथ या उसके बिना किया जा सकता है।
एक तालिका Orders मानिए जिसमें order_id, customer,
city, amount कॉलम हैं।
-- नमूना डेटा SELECT * FROM Orders; +----------+----------+--------+--------+ | order_id | customer | city | amount | +----------+----------+--------+--------+ | 1 | Alice | Delhi | 500 | | 2 | Bob | Mumbai | 700 | | 3 | Carol | Delhi | 300 | | 4 | Dave | Mumbai | 200 | | 5 | Eve | Delhi | 400 | | 6 | Frank | Pune | 600 | +----------+----------+--------+--------+ -- शहर के अनुसार समूह, कुल राशि और गिनती प्राप्त करें SELECT city, SUM(amount) AS total_amt, COUNT(*) AS no_of_orders FROM Orders GROUP BY city; +--------+-----------+---------------+ | city | total_amt | no_of_orders | +--------+-----------+---------------+ | Delhi | 1200 | 3 | | Mumbai | 900 | 2 | | Pune | 600 | 1 | +--------+-----------+---------------+ -- समूह फ़िल्टर करें: केवल वे शहर जहाँ 1 से अधिक ऑर्डर हैं SELECT city, SUM(amount) AS total_amt FROM Orders GROUP BY city HAVING COUNT(*) > 1; +--------+-----------+ | city | total_amt | +--------+-----------+ | Delhi | 1200 | | Mumbai | 900 | +--------+-----------+ -- कुल राशि के अवरोही क्रम में क्रमबद्ध करें SELECT city, SUM(amount) AS total_amt FROM Orders GROUP BY city ORDER BY total_amt DESC; +--------+-----------+ | city | total_amt | +--------+-----------+ | Delhi | 1200 | | Mumbai | 900 | | Pune | 600 | +--------+-----------+
ORDER BY col1 ASC, col2 DESC – पहले
col1 फिर col2 के अनुसार क्रमबद्ध करता है।ORDER BY 2 DESC SELECT सूची के दूसरे स्तंभ
के अनुसार क्रमबद्ध करता है।HAVING city = 'Delhi' जैसी शर्त स्वीकार्य है लेकिन उसे WHERE में रखना बेहतर है।GROUP BY col1, col2 हर अद्वितीय संयोजन के लिए
समूह बनाता है।
+----------------+
| FROM | (तालिकाएँ पढ़ें)
+-------+--------+
|
v
+----------------+
| WHERE | (पंक्तियाँ फ़िल्टर करें)
+-------+--------+
|
v
+----------------+
| GROUP BY | (समूह बनाएँ)
+-------+--------+
|
v
+----------------+
| HAVING | (समूह फ़िल्टर करें)
+-------+--------+
|
v
+----------------+
| SELECT | (स्तंभ चुनें, एग्रीगेट गणना करें)
+-------+--------+
|
v
+----------------+
| ORDER BY | (अंतिम परिणाम क्रमबद्ध करें)
+-------+--------+
|
v
[ अंतिम आउटपुट ]
यह आरेख SQL खंडों के प्रसंस्करण का तार्किक क्रम दिखाता है। इसे समझने से सामान्य ग़लतियों से बचने में मदद मिलती है।
GROUP BY, HAVING, और ORDER BY कच्चे डेटा को सार्थक, क्रमबद्ध सारांश में बदलने के लिए अनिवार्य उपकरण हैं। GROUP BY पंक्तियों को श्रेणियों में संक्षिप्त करता है; HAVING उन श्रेणियों को एग्रीगेट मानों के आधार पर फ़िल्टर करता है; ORDER BY अंतिम आउटपुट को व्यवस्थित करता है। इन खंडों में निपुणता आपको सीधे SQL में शक्तिशाली विश्लेषणात्मक क्वेरी लिखने योग्य बनाती है, जिससे बाहरी डेटा हेरफेर की आवश्यकता कम हो जाती है। निष्पादन क्रम, WHERE और HAVING के बीच अंतर, तथा समूहीकरण से जुड़े स्तंभ प्रतिबंधों को हमेशा ध्यान में रखें।
students तालिका (name, city) से प्रत्येक शहर में छात्रों की
संख्या गिनने की क्वेरी लिखिए।results तालिका (subject, marks) से प्रत्येक विषय में अधिकतम
और न्यूनतम अंक प्रदर्शित कीजिए। परिणाम को अधिकतम अंकों के अवरोही क्रम में क्रमबद्ध करें।WHERE और HAVING में क्या अंतर है? एक उदाहरण दीजिए जिसमें दोनों का एक साथ
उपयोग हुआ हो।employees तालिका (dept, salary) से प्रत्येक विभाग में कुल
वेतन ज्ञात कीजिए। केवल उन विभागों को शामिल करें जिनका कुल वेतन 200,000 से अधिक हो और परिणाम कुल वेतन
के अवरोही क्रम में दिखाएँ।GROUP BY खंड में स्तंभ उपनाम का उपयोग कर सकते हैं? उदाहरण सहित उत्तर की पुष्टि
कीजिए।
In a well‑designed relational database, data is split into multiple tables to avoid redundancy
(normalization).
For example, employee details may be in one table while department names are in another, linked by a
common column like dept_id.
A simple SELECT on one table cannot answer questions like "list all employees along with
their department name".
The problem is: how to combine rows from two or more tables based on a matching column to
produce a single meaningful result set.
This is where joins, especially the equi‑join, come in.
Equi‑Join : A type of join that combines rows from two or more tables based on an
equality condition between a common column (or set of columns).
The join condition uses the = operator in the ON clause (or in the
WHERE clause for implicit joins).
It is the most common type of inner join.
Only rows that satisfy the equality condition appear in the result.
Consider two tables: Employees and Departments.
-- Employees table +----+----------+---------+ | id | name | dept_id | +----+----------+---------+ | 1 | Alice | 10 | | 2 | Bob | 20 | | 3 | Carol | 10 | | 4 | Dave | NULL | +----+----------+---------+ -- Departments table +---------+------------+ | dept_id | dept_name | +---------+------------+ | 10 | IT | | 20 | HR | | 30 | Finance | +---------+------------+
Explicit equi‑join (ANSI style) :
SELECT Employees.name, Departments.dept_name FROM Employees JOIN Departments ON Employees.dept_id = Departments.dept_id;
Output:
+-------+-----------+ | name | dept_name | +-------+-----------+ | Alice | IT | | Bob | HR | | Carol | IT | +-------+-----------+
Notice: Dave (NULL dept_id) is excluded, and Finance department (30) is not shown because no employee matches it.
Implicit equi‑join (older syntax) :
SELECT Employees.name, Departments.dept_name FROM Employees, Departments WHERE Employees.dept_id = Departments.dept_id;
Both produce the same result.
JOIN ... ON clause (preferred for clarity).
FROM with equality condition in
WHERE.NATURAL JOIN automatically joins on columns with the
same name. No need to specify ON; MySQL matches identically named columns.JOIN ... USING(common_column) when columns have exactly
the same name.JOIN ... ON syntax clearly shows the
relationship.SELECT * may return duplicate
column names, causing ambiguity.table.column) to avoid errors.= operator in the join predicate.
e, d) simplifies the
query.
Employees (E) Departments (D)
+----+--------+ +---------+----------+
| id | dept_id| | dept_id | dept_name|
+----+--------+ +---------+----------+
| 1 | 10 |────────>| 10 | IT |
| 3 | 10 |──┐ | 20 | HR |
+----+--------+ │ | 30 | Finance |
│ +---------+----------+
| 2 | 20 |──┘ (matches 20 = 20)
+----+--------+
| 4 | NULL | (no match; excluded)
+----+--------+
Result (after equi‑join on dept_id):
+-------+-----------+
| name | dept_name |
+-------+-----------+
| Alice | IT |
| Carol | IT |
| Bob | HR |
+-------+-----------+
Only rows where E.dept_id = D.dept_id are included. Non‑matching rows are silently
discarded.
The equi‑join is a fundamental operation in SQL that brings related data together from multiple tables
using equality conditions.
Mastering explicit JOIN ... ON syntax, understanding how NULLs affect results, and using
table aliases are crucial for writing efficient and correct queries.
Equi‑joins respect database normalization and allow powerful data retrieval without redundancy.
However, always ensure proper indexing on join columns and carefully test for unintended Cartesian
products.
students(id, name, class_id) and
classes(class_id, class_name), write a query to display student names along with their
class names using an equi‑join.orders(order_id, cust_id, amount) with customers(cust_id, cust_name)
and show cust_name and amount. Use table aliases o and
c.NATURAL JOIN is different from an equi‑join written with
JOIN ... ON.employees, departments, and
locations (departments has loc_id, locations has loc_id and city). Display employee
name, department name, and city.
एक सुव्यवस्थित रिलेशनल डेटाबेस में, डेटा अतिरेक से बचने के लिए अनेक तालिकाओं में विभाजित किया जाता है
(नॉर्मलाइज़ेशन)।
उदाहरण के लिए, कर्मचारी विवरण एक तालिका में हो सकता है और विभाग के नाम दूसरी तालिका में, जो
dept_id जैसे सामान्य स्तंभ से जुड़े हों।
एक तालिका पर साधारण SELECT "सभी कर्मचारियों को उनके विभाग के नाम सहित सूचीबद्ध करें" जैसे
प्रश्नों का उत्तर नहीं दे सकता।
समस्या है: एक समान मिलान स्तंभ के आधार पर दो या अधिक तालिकाओं से पंक्तियों को कैसे संयोजित करें
ताकि एकल सार्थक परिणाम सेट प्राप्त हो।
यहीं जॉइन, विशेषकर equi-join, काम आते हैं।
Equi-Join : एक प्रकार का जॉइन जो एक सामान्य स्तंभ (या स्तंभों के समूह) के बीच समानता
शर्त (=) के आधार पर दो या अधिक तालिकाओं से पंक्तियाँ जोड़ता है।
यह इनर जॉइन का सबसे सामान्य रूप है। परिणाम में केवल वे पंक्तियाँ शामिल होती हैं जो समानता शर्त संतुष्ट
करती हैं।
दो तालिकाएँ मानिए: Employees और Departments।
-- Employees तालिका +----+----------+---------+ | id | name | dept_id | +----+----------+---------+ | 1 | Alice | 10 | | 2 | Bob | 20 | | 3 | Carol | 10 | | 4 | Dave | NULL | +----+----------+---------+ -- Departments तालिका +---------+------------+ | dept_id | dept_name | +---------+------------+ | 10 | IT | | 20 | HR | | 30 | Finance | +---------+------------+
स्पष्ट equi-join (ANSI शैली) :
SELECT Employees.name, Departments.dept_name FROM Employees JOIN Departments ON Employees.dept_id = Departments.dept_id;
आउटपुट:
+-------+-----------+ | name | dept_name | +-------+-----------+ | Alice | IT | | Bob | HR | | Carol | IT | +-------+-----------+
ध्यान दें: Dave (NULL dept_id) को बाहर रखा गया और Finance विभाग (30) नहीं दिखा क्योंकि कोई कर्मचारी उससे मेल नहीं खाता।
अस्पष्ट equi-join (पुरानी शैली) :
SELECT Employees.name, Departments.dept_name FROM Employees, Departments WHERE Employees.dept_id = Departments.dept_id;
JOIN ... ON खंड का उपयोग करता है (स्पष्टता के लिए
पसंदीदा)।FROM में तालिकाएँ सूचीबद्ध, WHERE में
समानता शर्त।NATURAL JOIN समान नाम वाले स्तंभों पर
स्वचालित रूप से जोड़ता है।JOIN ... USING(common_column) जब स्तंभ का नाम बिल्कुल समान
हो।JOIN ... ON सिंटैक्स संबंध को साफ़ दिखाता है।SELECT * से समान नाम वाले स्तंभ दो बार आ सकते हैं,
जिससे अस्पष्टता होती है।table.column
रूप में उपनाम का प्रयोग ज़रूरी है।= ऑपरेटर का उपयोग करता है।e, d) क्वेरी सरल बनाते हैं।
Employees (E) Departments (D)
+----+--------+ +---------+----------+
| id | dept_id| | dept_id | dept_name|
+----+--------+ +---------+----------+
| 1 | 10 |────────>| 10 | IT |
| 3 | 10 |──┐ | 20 | HR |
+----+--------+ │ | 30 | Finance |
│ +---------+----------+
| 2 | 20 |──┘ (मिलान 20 = 20)
+----+--------+
| 4 | NULL | (कोई मिलान नहीं; बाहर)
+----+--------+
परिणाम (dept_id पर equi-join के बाद):
+-------+-----------+
| name | dept_name |
+-------+-----------+
| Alice | IT |
| Carol | IT |
| Bob | HR |
+-------+-----------+
केवल वे पंक्तियाँ शामिल हैं जहाँ E.dept_id = D.dept_id। बेमेल पंक्तियाँ चुपचाप हटा दी जाती
हैं।
Equi-join SQL की एक मूलभूत संक्रिया है जो समानता शर्तों का उपयोग करके अनेक तालिकाओं से संबंधित डेटा एक
साथ लाती है।
स्पष्ट JOIN ... ON सिंटैक्स में निपुणता, NULL का प्रभाव समझना, और तालिका उपनामों का उपयोग
कुशल और सही क्वेरी लिखने के लिए आवश्यक है।
Equi-join डेटाबेस नॉर्मलाइज़ेशन का सम्मान करते हुए बिना अतिरेक के शक्तिशाली डेटा पुनर्प्राप्ति सक्षम
करते हैं।
फिर भी, जॉइन स्तंभों पर उचित इंडेक्स सुनिश्चित करें और अनजाने कार्टीज़ियन उत्पादों का सावधानीपूर्वक
परीक्षण करें।
students(id, name, class_id) और classes(class_id, class_name) तालिकाएँ दी
गई हैं। equi-join का उपयोग करके विद्यार्थी के नाम उनकी कक्षा के नाम सहित दिखाने की क्वेरी लिखिए।
orders(order_id, cust_id, amount) को customers(cust_id, cust_name) से
जोड़ें और cust_name व amount दिखाएँ। तालिका उपनाम o और
c का उपयोग करें।NATURAL JOIN, JOIN ... ON वाले equi-join से किस प्रकार भिन्न है।
employees, departments, और locations
(departments में loc_id है, locations में loc_id और city है) को जोड़ने की क्वेरी लिखिए। कर्मचारी का
नाम, विभाग का नाम और शहर दिखाइए।Writing a program from scratch every time is tedious and time‑consuming. Many common tasks — mathematical calculations, reading files, sending emails, creating graphs — have already been solved by other developers. Re‑inventing the wheel leads to longer development time, more bugs, and larger codebases. The core problem is: how can we reuse existing, well‑tested code so that we can focus on the unique logic of our application? Libraries solve this by bundling pre‑written functions and classes that can be easily imported into any program.
Library : A collection of pre‑compiled routines (functions, classes, variables) that a program can use. Libraries provide a way to reuse code that has already been written and tested, reducing development effort. In Python, libraries are often called modules (single file) or packages (a collection of modules).
Python example – using the math library :
import math # Using functions from the math library print(math.sqrt(25)) # 5.0 print(math.pow(2, 3)) # 8.0 print(math.pi) # 3.141592653589793
Using a third‑party library – requests :
import requests
response = requests.get('https://api.example.com/data')
print(response.status_code)
Without libraries, you would have to write hundreds of lines just to make an HTTP request.
Types of Libraries :
math,
os, datetime in Python). No installation needed.pip (Python), npm (JavaScript). Examples:
numpy, pandas, matplotlib..py file and importing it into other projects..lib / .a) or dynamic/shared (.dll / .so).How to bring a library into a program (importing) :
import mathfrom math import sqrt, powimport numpy as npfrom math import *pip install library_name before
importing.
+----------------------------------+
| Your Program (main.py) |
+---------------+------------------+
|
+-----------+-----------+
| |
v v
+--------+ +----------+
| Module1| | Module2 |
| (math) | | (numpy) |
+--------+ +----------+
| |
v v
+-------------------------------+
| Standard Library / |
| Third‑party packages |
+-------------------------------+
Your program imports modules from the standard library or installed third‑party packages. Each module provides specific functionality.
Libraries are the building blocks of modern software development. They save time, improve code quality, and allow us to stand on the shoulders of giants. Understanding the types of libraries, how to install them, and the different ways of importing them is essential for every programmer. While libraries bring many benefits, one must also manage dependencies carefully to keep the codebase secure and maintainable.
math library and prints the ceiling value of 4.3.randint function from the random module?
Show the syntax.from module import * is generally discouraged.emoji in Python.हर बार प्रोग्राम को शून्य से लिखना थकाऊ और समय लेने वाला होता है। कई सामान्य कार्य – गणितीय गणना, फ़ाइल पढ़ना, ईमेल भेजना, ग्राफ़ बनाना – पहले से अन्य डेवलपर्स द्वारा हल किए जा चुके हैं। पहिए का पुनः आविष्कार करने से विकास का समय बढ़ता है, अधिक बग आते हैं और कोडबेस बड़ा हो जाता है। मुख्य समस्या है: हम पहले से लिखे, परीक्षण किए गए कोड का पुनः उपयोग कैसे करें ताकि हम अपने अनुप्रयोग के अनूठे तर्क पर ध्यान केंद्रित कर सकें? लाइब्रेरी पूर्व‑लिखित फंक्शन और क्लास का बंडल देकर इसे हल करती हैं जिन्हें किसी भी प्रोग्राम में आसानी से आयात किया जा सकता है।
लाइब्रेरी : पूर्व‑संकलित रूटीन (फंक्शन, क्लास, वेरिएबल) का एक संग्रह जिसे प्रोग्राम उपयोग कर सकता है। लाइब्रेरी कोड पुनः उपयोग का एक तरीका प्रदान करती हैं जो पहले से लिखा और परीक्षित होता है, विकास प्रयास को कम करता है। Python में लाइब्रेरी को प्रायः मॉड्यूल (एकल फ़ाइल) या पैकेज (मॉड्यूल का संग्रह) कहा जाता है।
Python उदाहरण – math लाइब्रेरी का उपयोग :
import math # math लाइब्रेरी से फंक्शनों का उपयोग print(math.sqrt(25)) # 5.0 print(math.pow(2, 3)) # 8.0 print(math.pi) # 3.141592653589793
तृतीय‑पक्ष लाइब्रेरी – requests :
import requests
response = requests.get('https://api.example.com/data')
print(response.status_code)
लाइब्रेरी के बिना, केवल HTTP अनुरोध करने के लिए सैकड़ों पंक्तियाँ लिखनी पड़तीं।
लाइब्रेरी के प्रकार :
math, os, datetime)। कोई स्थापना आवश्यक नहीं।pip (Python), npm (JavaScript) से अलग से स्थापित की जाती हैं। उदाहरण:
numpy, pandas, matplotlib।.py फ़ाइल में फंक्शन सहेजकर स्वयं
मॉड्यूल बना सकते हैं और अन्य प्रोजेक्ट में आयात कर सकते हैं।.lib / .a) या डायनामिक/शेयर्ड (.dll / .so) हो
सकती हैं।लाइब्रेरी को प्रोग्राम में लाने के तरीके (आयात करना) :
import mathfrom math import sqrt, powimport numpy as npfrom math import *pip install library_name का उपयोग करें।
+----------------------------------+
| आपका प्रोग्राम (main.py) |
+---------------+------------------+
|
+-----------+-----------+
| |
v v
+--------+ +----------+
| मॉड्यूल1| | मॉड्यूल2 |
| (math) | | (numpy) |
+--------+ +----------+
| |
v v
+-------------------------------+
| मानक लाइब्रेरी / |
| तृतीय‑पक्ष पैकेज |
+-------------------------------+
आपका प्रोग्राम मानक लाइब्रेरी या स्थापित तृतीय‑पक्ष पैकेज से मॉड्यूल आयात करता है। प्रत्येक मॉड्यूल विशिष्ट कार्यक्षमता प्रदान करता है।
लाइब्रेरी आधुनिक सॉफ़्टवेयर विकास के निर्माण खंड हैं। वे समय बचाती हैं, कोड गुणवत्ता सुधारती हैं, और हमें दिग्गजों के कंधों पर खड़ा होने देती हैं। लाइब्रेरी के प्रकारों, उन्हें कैसे स्थापित करें और आयात करने के विभिन्न तरीकों को समझना हर प्रोग्रामर के लिए अनिवार्य है। जहाँ लाइब्रेरी कई लाभ लाती हैं, वहीं कोडबेस को सुरक्षित और रखरखाव योग्य रखने के लिए निर्भरताओं का सावधानीपूर्वक प्रबंधन भी आवश्यक है।
math लाइब्रेरी आयात करे और 4.3 का सीलिंग मान मुद्रित करे।random मॉड्यूल से केवल randint फंक्शन कैसे आयात करेंगे? सिंटैक्स
दिखाइए।from module import * को सामान्यतः हतोत्साहित क्यों किया जाता है।emoji नामक तृतीय‑पक्ष लाइब्रेरी स्थापित करने और उपयोग करने के चरण सूचीबद्ध
कीजिए।Raw data is rarely ready for analysis. It often arrives as messy tables, missing values, or different formats (CSV, Excel, JSON). After cleaning and processing, we need to understand patterns, trends, and outliers. Manually doing this with base Python requires writing long loops and logic, which is inefficient and error‑prone. The core problem is: how to efficiently load, clean, transform, and visualize data without writing thousands of lines of custom code? Pandas solves the data manipulation part, while Matplotlib handles the visualization.
Pandas : An open‑source Python library that provides high‑performance, easy‑to‑use data
structures (Series and DataFrame)
and data analysis tools. It is built on top of NumPy and is ideal for handling structured (tabular)
data.
Matplotlib : A comprehensive Python library for creating static, animated, and
interactive visualizations.
Its pyplot module provides a MATLAB‑like interface for generating plots (line, bar,
scatter, histogram, etc.).
Using Pandas to load and analyze data :
import pandas as pd
# Create a DataFrame from a dictionary
data = {'Name': ['Alice', 'Bob', 'Carol'],
'Age': [25, 30, 28],
'City': ['Delhi', 'Mumbai', 'Pune']}
df = pd.DataFrame(data)
print(df)
print(df.describe()) # statistical summary
print(df['Age'].mean()) # average age
Using Matplotlib to visualize the data :
import matplotlib.pyplot as plt
# Bar plot of ages
plt.bar(df['Name'], df['Age'], color='skyblue')
plt.xlabel('Name')
plt.ylabel('Age')
plt.title('Age of Individuals')
plt.show()
These two libraries often work together: Pandas for data preparation, Matplotlib for plotting.
Pandas Core Structures :
Matplotlib Plot Types :
plot() – trends over time.bar() / barh() – categorical comparisons.
hist() – frequency distribution.scatter() – relationship between two variables.pie() – part‑to‑whole relationship.dropna(),
fillna() simplify missing value treatment.
Raw Data (CSV, Excel, JSON)
|
v
+-----------------+
| Pandas DataFrame | (Load, Clean, Transform)
+--------+--------+
|
v
+-----------------+
| Matplotlib Plot | (Visualize, Explore)
+-----------------+
A typical workflow: use Pandas to wrangle data, then feed the prepared data to Matplotlib for graphing.
Pandas and Matplotlib form the core of Python's data analysis stack. Pandas turns messy data into structured, analyzable tables; Matplotlib brings those numbers to life through graphs and charts. Together they empower data scientists, analysts, and students to extract insights quickly and present them effectively. A solid understanding of both libraries is essential for anyone working with data in Python.
pyplot module in Matplotlib.sales.csv, write code to load it into a DataFrame and plot a line
chart of monthly sales.कच्चा डेटा शायद ही कभी विश्लेषण के लिए तैयार होता है। यह अक्सर अस्त‑व्यस्त तालिकाओं, अनुपलब्ध मानों, या विभिन्न प्रारूपों (CSV, Excel, JSON) में आता है। सफाई और प्रसंस्करण के बाद, हमें पैटर्न, रुझान और बाहरी बिंदुओं को समझना होता है। सामान्य Python के साथ ऐसा करने के लिए लंबे लूप और तर्क लिखने पड़ते हैं, जो अक्षम और त्रुटि‑संभावी है। मुख्य समस्या है: कस्टम कोड की हज़ारों पंक्तियाँ लिखे बिना डेटा को कुशलता से लोड, साफ़, रूपांतरित और दृश्यमान कैसे करें? Pandas डेटा हेरफेर का भाग हल करता है, जबकि Matplotlib दृश्यीकरण का कार्य संभालता है।
Pandas : एक ओपन‑सोर्स Python लाइब्रेरी जो उच्च‑प्रदर्शन, उपयोग में आसान डेटा संरचनाएँ
(Series और DataFrame)
और डेटा विश्लेषण उपकरण प्रदान करती है। यह NumPy के ऊपर बनी है और संरचित (सारणीबद्ध) डेटा के लिए आदर्श
है।
Matplotlib : स्थिर, एनिमेटेड और इंटरैक्टिव दृश्यीकरण बनाने के लिए एक व्यापक Python
लाइब्रेरी।
इसका pyplot मॉड्यूल ग्राफ़ (रेखा, दंड, बिखराव, हिस्टोग्राम आदि) बनाने के लिए MATLAB जैसा
इंटरफ़ेस देता है।
Pandas का उपयोग करके डेटा लोड और विश्लेषण :
import pandas as pd
# डिक्शनरी से DataFrame बनाना
data = {'नाम': ['ऐलिस', 'बॉब', 'कैरोल'],
'आयु': [25, 30, 28],
'शहर': ['दिल्ली', 'मुंबई', 'पुणे']}
df = pd.DataFrame(data)
print(df)
print(df.describe()) # सांख्यिकीय सारांश
print(df['आयु'].mean()) # औसत आयु
Matplotlib से डेटा का दृश्यीकरण :
import matplotlib.pyplot as plt
# आयु का दंड आरेख
plt.bar(df['नाम'], df['आयु'], color='skyblue')
plt.xlabel('नाम')
plt.ylabel('आयु')
plt.title('व्यक्तियों की आयु')
plt.show()
ये दोनों लाइब्रेरी अक्सर साथ काम करती हैं: Pandas डेटा तैयारी के लिए, Matplotlib आलेखन के लिए।
Pandas की मुख्य संरचनाएँ :
Matplotlib के आलेख प्रकार :
plot() – समय के साथ रुझान।bar() / barh() – श्रेणीगत तुलना।hist() – आवृत्ति वितरण।scatter() – दो चरों के बीच संबंध।pie() – भाग‑से‑संपूर्ण संबंध।dropna(), fillna() जैसी
अंतर्निहित विधियाँ अनुपलब्ध मानों का उपचार सरल करती हैं।
कच्चा डेटा (CSV, Excel, JSON)
|
v
+-----------------+
| Pandas DataFrame | (लोड, साफ़, रूपांतरित)
+--------+--------+
|
v
+-----------------+
| Matplotlib आलेख | (दृश्य, अन्वेषण)
+-----------------+
सामान्य कार्यप्रवाह: Pandas से डेटा व्यवस्थित करें, फिर तैयार डेटा को Matplotlib में ग्राफ़ बनाने के लिए भेजें।
Pandas और Matplotlib Python के डेटा विश्लेषण स्टैक का मूल हैं। Pandas अस्त‑व्यस्त डेटा को संरचित, विश्लेषण योग्य तालिकाओं में बदलता है; Matplotlib उन संख्याओं को ग्राफ़ और चार्ट के माध्यम से जीवंत करता है। साथ मिलकर, ये डेटा वैज्ञानिकों, विश्लेषकों और छात्रों को तेज़ी से अंतर्दृष्टि निकालने और प्रभावी ढंग से प्रस्तुत करने में सशक्त बनाते हैं। Python में डेटा के साथ काम करने वाले किसी भी व्यक्ति के लिए दोनों लाइब्रेरी की ठोस समझ अनिवार्य है।
pyplot मॉड्यूल का उद्देश्य समझाइए।sales.csv दी गई है, उसे DataFrame में लोड करने और मासिक बिक्री का रेखा
चार्ट बनाने का कोड लिखिए।When we work with real-world data, we often deal with rows and columns (like a spreadsheet or a database table). Python’s built‑in lists and dictionaries are not enough for efficient handling of such structured data – they lack labelled axes, automatic alignment, and fast built‑in methods for statistics, grouping, or handling missing values. Writing custom code for every such operation is time‑consuming and error‑prone. The core problem is: how to store and manipulate structured, labelled data easily and efficiently in Python. Pandas solves this with two powerful, flexible data structures – Series and DataFrame.
Series : A one‑dimensional labelled array capable of holding data of any type (integer,
float, string, Python object, etc.).
It consists of two parts: a sequence of values and an associated array of labels called the
index. You can think of a Series as a single column in a spreadsheet.
DataFrame : A two‑dimensional, size‑mutable, potentially heterogeneous tabular data
structure.
It has labelled axes – rows (index) and columns. A DataFrame is like a spreadsheet or SQL table, where
each column can be of a different data type.
Creating a Series :
import pandas as pd
# From a list
s1 = pd.Series([10, 20, 30, 40])
print(s1)
# Output:
# 0 10
# 1 20
# 2 30
# 3 40
# dtype: int64
# From a dictionary (keys become index)
s2 = pd.Series({'a': 100, 'b': 200, 'c': 300})
print(s2)
# Output:
# a 100
# b 200
# c 300
# dtype: int64
Creating a DataFrame :
# From a dictionary of lists
df = pd.DataFrame({
'Name': ['Alice', 'Bob', 'Carol'],
'Age': [25, 30, 28],
'City': ['Delhi', 'Mumbai', 'Pune']
})
print(df)
# Output:
# Name Age City
# 0 Alice 25 Delhi
# 1 Bob 30 Mumbai
# 2 Carol 28 Pune
# Read from a CSV file (example)
# df = pd.read_csv('students.csv')
isna(),
fillna(), dropna() simplify dealing with gaps.groupby(), merge(),
join() enable complex data manipulation easily..index, .columns, .shape,
.dtypes, .values provide quick meta‑information..loc[] for label‑based, .iloc[] for
integer‑position‑based access.
Series:
Index | Values
-------+--------
0 | 10
1 | 20
2 | 30
3 | 40
DataFrame:
columns
index Name Age City
0 Alice 25 Delhi
1 Bob 30 Mumbai
2 Carol 28 Pune
rows
A Series is like a single labelled column; a DataFrame is a collection of Series sharing the same row index.
Series and DataFrame are the core building blocks of data manipulation in Python with Pandas. They bring the ease of labelled data handling, powerful vectorized operations, and seamless I/O to your workflow. Understanding these two structures, how to create them, and their properties is the first and most important step toward becoming proficient in data analysis with Python.
pd.Series([1, 2, 3]) + pd.Series([10, 20, 30])? Explain the
result.df? Show two different ways.employees.csv into a DataFrame and display the first 5 rows..loc[] and .iloc[]? Give an example using a
DataFrame.जब हम वास्तविक दुनिया के डेटा के साथ काम करते हैं, तो हम अक्सर पंक्तियों और स्तंभों (स्प्रेडशीट या डेटाबेस तालिका जैसा) का सामना करते हैं। Python की अंतर्निहित सूचियाँ (lists) और शब्दकोश (dictionaries) ऐसे संरचित डेटा को कुशलतापूर्वक संभालने के लिए पर्याप्त नहीं हैं – उनमें नामांकित अक्ष, स्वचालित संरेखण और सांख्यिकी, समूहीकरण या अनुपलब्ध मानों के लिए तीव्र अंतर्निहित विधियों का अभाव है। हर बार ऐसी संक्रिया के लिए कस्टम कोड लिखना समय लेने वाला और त्रुटिपूर्ण होता है। मुख्य समस्या है: Python में संरचित, नामांकित डेटा को आसानी से और कुशलतापूर्वक कैसे संग्रहीत और हेरफेर किया जाए। Pandas इसे दो शक्तिशाली, लचीली डेटा संरचनाओं – Series और DataFrame – के साथ हल करता है।
Series : एक एक‑आयामी नामांकित सरणी जो किसी भी प्रकार का डेटा (पूर्णांक, फ़्लोट,
स्ट्रिंग, Python ऑब्जेक्ट, आदि) धारण कर सकती है।
इसके दो भाग होते हैं: मानों का एक क्रम और उससे जुड़ा हुआ लेबलों का सरणी जिसे index कहते
हैं। Series को स्प्रेडशीट का एक स्तंभ समझ सकते हैं।
DataFrame : एक द्वि‑आयामी, आकार‑परिवर्तनीय, विभिन्न प्रकार की सारणीबद्ध डेटा संरचना।
इसमें नामांकित अक्ष होते हैं – पंक्तियाँ (index) और स्तंभ। DataFrame एक स्प्रेडशीट या SQL तालिका जैसा
है, जहाँ हर स्तंभ भिन्न डेटा प्रकार का हो सकता है।
Series बनाना :
import pandas as pd
# सूची से
s1 = pd.Series([10, 20, 30, 40])
print(s1)
# Output:
# 0 10
# 1 20
# 2 30
# 3 40
# dtype: int64
# शब्दकोश से (कुंजियाँ index बन जाती हैं)
s2 = pd.Series({'a': 100, 'b': 200, 'c': 300})
print(s2)
# Output:
# a 100
# b 200
# c 300
# dtype: int64
DataFrame बनाना :
# सूचियों के शब्दकोश से
df = pd.DataFrame({
'नाम': ['ऐलिस', 'बॉब', 'कैरोल'],
'आयु': [25, 30, 28],
'शहर': ['दिल्ली', 'मुंबई', 'पुणे']
})
print(df)
# Output:
# नाम आयु शहर
# 0 ऐलिस 25 दिल्ली
# 1 बॉब 30 मुंबई
# 2 कैरोल 28 पुणे
# CSV फ़ाइल से पढ़ना (उदाहरण)
# df = pd.read_csv('students.csv')
isna(), fillna(),
dropna() जैसी अंतर्निहित विधियाँ रिक्तियों से निपटना सरल बनाती हैं।groupby(), merge(),
join() जटिल डेटा हेरफेर सरल बनाते हैं।.index, .columns, .shape,
.dtypes, .values तुरंत मेटा‑जानकारी देते हैं।.loc[],
पूर्णांक‑स्थिति‑आधारित पहुँच के लिए .iloc[]।
Series:
Index | Values
-------+--------
0 | 10
1 | 20
2 | 30
3 | 40
DataFrame:
columns
index नाम आयु शहर
0 ऐलिस 25 दिल्ली
1 बॉब 30 मुंबई
2 कैरोल 28 पुणे
rows
Series एक नामांकित स्तंभ जैसा है; DataFrame समान पंक्ति अनुक्रमणिका साझा करने वाले Series का संग्रह है।
Series और DataFrame, Python में Pandas के साथ डेटा हेरफेर के मूल निर्माण खंड हैं। ये नामांकित डेटा प्रबंधन की सरलता, शक्तिशाली सदिशीकृत संक्रियाएँ और सहज I/O को आपके कार्यप्रवाह में लाते हैं। इन दोनों संरचनाओं, उन्हें कैसे बनाएँ और उनके गुणों को समझना, Python के साथ डेटा विश्लेषण में दक्ष बनने की दिशा में पहला और सबसे महत्वपूर्ण कदम है।
pd.Series([1, 2, 3]) + pd.Series([10, 20, 30]) का आउटपुट क्या होगा? परिणाम की व्याख्या
करें।df से 'Age' स्तंभ कैसे प्राप्त करेंगे? दो भिन्न तरीके दिखाइए।employees.csv नामक CSV फ़ाइल को DataFrame में पढ़ें और पहली 5 पंक्तियाँ प्रदर्शित करें।
.loc[] और .iloc[] में क्या अंतर है? DataFrame का उपयोग करके उदाहरण दीजिए।
When you have a sequence of numbers, a mapping of key‑value pairs, or even a single constant value that you want to repeat for several labels, Python’s built‑in lists or dictionaries cannot directly provide labelled axes, automatic alignment, or vectorized operations. Without a proper labelled data structure, it becomes cumbersome to perform arithmetic, handle missing values, or prepare data for a DataFrame. The core problem is: how to easily create a labelled, one‑dimensional array from common data sources – a NumPy array, a dictionary, or a scalar constant – with full control over the index. Pandas Series solves this elegantly.
Series : A one‑dimensional labelled array in Pandas that can hold data of any type (integers, floats, strings, objects, etc.). It consists of two main components: a sequence of values and an associated array of index labels. You can create a Series from:
index argument.1. From a NumPy ndarray :
import pandas as pd import numpy as np arr = np.array([100, 200, 300]) s1 = pd.Series(arr) print(s1) # Output: # 0 100 # 1 200 # 2 300 # dtype: int64 # With custom index s2 = pd.Series(arr, index=['a', 'b', 'c']) print(s2) # Output: # a 100 # b 200 # c 300 # dtype: int64
2. From a Dictionary :
data_dict = {'apple': 5, 'banana': 8, 'cherry': 3}
s3 = pd.Series(data_dict)
print(s3)
# Output:
# apple 5
# banana 8
# cherry 3
# dtype: int64
If you specify an index, only matching keys are used; missing keys become NaN.
s4 = pd.Series(data_dict, index=['apple', 'mango', 'cherry']) print(s4) # apple 5.0 # mango NaN # cherry 3.0 # dtype: float64
3. From a Scalar value :
s5 = pd.Series(7, index=['x', 'y', 'z']) print(s5) # Output: # x 7 # y 7 # z 7 # dtype: int64
NaN.index argument; the scalar is
broadcast to every index position.NaN, which is easy to handle later.ValueError is raised.NaN may upcast integers to float.dtype
(unless object dtype is forced)..index, even if it’s the
default RangeIndex.name for
documentation and merging.NaN.
Data Source → Series
--------------------------------
ndarray [10,20,30] → Index: 0,1,2 Values: 10,20,30
dict {'a':5,'b':8} → Index: a,b Values: 5,8
scalar 7 → Index: x,y,z Values: 7,7,7
Each path produces a labelled one‑dimensional array ready for analysis.
Creating a Pandas Series from a NumPy array, dictionary, or scalar value is the very first step in data analysis. It gives you complete control over index labels and integrates smoothly with the rest of the Pandas ecosystem. Understanding these three constructors – especially how missing keys and broadcasting work – helps you build correct, clean DataFrames and avoid common pitfalls.
np.array([1.5, 2.5, 3.5]) with the index
['first', 'second', 'third'].{'Mon':10, 'Tue':20, 'Wed':30}, create a Series. Then create another
Series from the same dictionary but with index ['Mon','Tue','Thu']. Explain the output.
'yes'. Use a scalar value.pd.Series(np.array([1,2,3]), index=['a','b'])? Why?['Aman', 'Rita'] (using a partial
index).{1: 10, 2: 20} versus from the same dictionary with an extra index
[1, 2, 3].जब आपके पास संख्याओं का अनुक्रम, कुंजी‑मूल्य युग्मों का मानचित्र, या एक स्थिर मान हो जिसे आप कई लेबलों के लिए दोहराना चाहते हैं, तो Python की अंतर्निहित सूचियाँ या शब्दकोश सीधे नामांकित अक्ष, स्वचालित संरेखण या सदिशीकृत संक्रियाएँ प्रदान नहीं कर सकते। एक उपयुक्त नामांकित डेटा संरचना के बिना, अंकगणित करना, अनुपलब्ध मानों को संभालना या DataFrame के लिए डेटा तैयार करना कठिन हो जाता है। मुख्य समस्या है: सामान्य डेटा स्रोतों – एक NumPy सरणी, एक शब्दकोश, या एक स्थिरांक – से पूर्ण नियंत्रण के साथ एक नामांकित, एक‑आयामी सरणी आसानी से कैसे बनाई जाए। Pandas Series इसे सुंदरता से हल करती है।
Series : Pandas में एक एक‑आयामी नामांकित सरणी जो किसी भी प्रकार का डेटा (पूर्णांक, फ़्लोट, स्ट्रिंग, ऑब्जेक्ट आदि) रख सकती है। इसके दो मुख्य भाग होते हैं: मानों का एक अनुक्रम और उनसे जुड़ी index लेबलों की एक सरणी। Series निम्न से बनाई जा सकती है:
index के हर लेबल के लिए दोहरा दी जाती है।1. NumPy ndarray से :
import pandas as pd import numpy as np arr = np.array([100, 200, 300]) s1 = pd.Series(arr) print(s1) # Output: # 0 100 # 1 200 # 2 300 # dtype: int64 # कस्टम index के साथ s2 = pd.Series(arr, index=['a', 'b', 'c']) print(s2) # Output: # a 100 # b 200 # c 300 # dtype: int64
2. शब्दकोश (Dictionary) से :
data_dict = {'सेब': 5, 'केला': 8, 'चेरी': 3}
s3 = pd.Series(data_dict)
print(s3)
# Output:
# सेब 5
# केला 8
# चेरी 3
# dtype: int64
यदि आप index सूची देते हैं, तो केवल मिलान वाली कुंजियाँ उपयोग होती हैं; अनुपलब्ध कुंजियाँ NaN बन जाती हैं।
s4 = pd.Series(data_dict, index=['सेब', 'आम', 'चेरी']) print(s4) # सेब 5.0 # आम NaN # चेरी 3.0 # dtype: float64
3. स्केलर मान (Scalar) से :
s5 = pd.Series(7, index=['x', 'y', 'z']) print(s5) # Output: # x 7 # y 7 # z 7 # dtype: int64
NaN हो जाती हैं।index तर्क देना अनिवार्य है; स्केलर हर index स्थान पर
प्रसारित होता है।NaN आता है, जिसे बाद में संभालना आसान है।ValueError उत्पन्न होता है।NaN
आने से पूर्णांक फ़्लोट में बदल सकते हैं।dtype का डेटा रखती है (जब तक
object dtype बाध्य न किया जाए)।.index से सुलभ, चाहे वह डिफ़ॉल्ट RangeIndex ही क्यों
न हो।name दिया जा सकता है।NaN
उत्पन्न करता है।
डेटा स्रोत → Series
--------------------------------
ndarray [10,20,30] → Index: 0,1,2 Values: 10,20,30
dict {'a':5,'b':8} → Index: a,b Values: 5,8
scalar 7 → Index: x,y,z Values: 7,7,7
प्रत्येक पथ एक नामांकित एक‑आयामी सरणी बनाता है जो विश्लेषण के लिए तैयार है।
NumPy सरणी, शब्दकोश या स्केलर मान से Pandas Series बनाना डेटा विश्लेषण का पहला कदम है। यह आपको index लेबलों पर पूर्ण नियंत्रण देता है और Pandas पारिस्थितिकी तंत्र के बाकी हिस्सों के साथ सहजता से एकीकृत होता है। इन तीन निर्माणकर्ताओं को समझना – विशेषकर अनुपलब्ध कुंजियों और प्रसारण का व्यवहार – आपको सही, स्वच्छ DataFrame बनाने और सामान्य गलतियों से बचने में मदद करता है।
np.array([1.5, 2.5, 3.5]) से ['first', 'second', 'third'] index
के साथ Series बनाइए।{'सोम':10, 'मंगल':20, 'बुध':30} दिया है। पहले एक Series बनाइए। फिर उसी शब्दकोश
से किन्तु index ['सोम','मंगल','गुरु'] के साथ दूसरी Series बनाइए। आउटपुट की व्याख्या
करें।'yes' हो। स्केलर मान का प्रयोग करें।pd.Series(np.array([1,2,3]), index=['a','b']) करें तो क्या त्रुटि आएगी? क्यों?
['अमन', 'रीता'] में हैं (आंशिक index
का प्रयोग करके)।{1: 10, 2: 20} से Series बनाने पर तथा इसी शब्दकोश से अतिरिक्त index
[1, 2, 3] के साथ Series बनाने पर डेटा प्रकार में क्या अंतर आता है? समझाइए।
After loading data into a Pandas Series or DataFrame, you immediately face several needs:
• Quick inspection: What does the data look like? The first few rows? The last few?
• Data extraction: How do you get a single column, a range of rows, or specific cells?
• Computation: How do you perform element‑wise arithmetic (addition, multiplication) on entire columns or rows efficiently without writing loops?
Without built‑in methods, you would have to iterate manually, check indices, and write custom logic — slow, error‑prone, and hard to read.
The core problem is: how to quickly explore, slice, and compute on labelled data using a simple, expressive syntax.
Pandas addresses this with head/tail for previews, flexible indexing/slicing (.loc, .iloc, []), and vectorized mathematical operations.
Mathematical Operations: In Pandas, arithmetic operators (+, -, *, /, **, %) work element‑wise on Series and DataFrames.
Operations automatically align on index labels. You can also use methods like .add(), .mul() for greater control (e.g., fill values).
Head and Tail:
df.head(n) returns the first n rows (default 5).df.tail(n) returns the last n rows (default 5).df['column_name'] or df.column_name (for single column).df.loc[row_label_start:row_label_end, column_labels] — includes both endpoints.df.iloc[row_start:row_end, col_start:col_end] — excludes the end index (like Python slices).df[df['column'] > value] to filter rows based on a condition.Consider a small DataFrame:
import pandas as pd
data = {'Name':['Alice','Bob','Carol','Dave','Eve'],
'Age':[25,30,22,35,28],
'Score':[88,92,75,85,90]}
df = pd.DataFrame(data)
Mathematical operations:
# Add 5 to every Age (element‑wise) df['Age'] + 5 # Series: 30,35,27,40,33 # Double the Score column df['Score'] * 2 # Series: 176,184,150,170,180 # Create new column from two columns df['Total'] = df['Age'] + df['Score'] # 113,122,97,120,118
Head & Tail:
df.head(3) # first 3 rows df.tail(2) # last 2 rows
Selection, Indexing & Slicing:
# Column selection df['Name'] # Series of names # Label‑based slicing: rows 0 to 2 (inclusive) and columns 'Name' and 'Score' df.loc[0:2, ['Name','Score']] # Integer‑position slicing: first 3 rows, first 2 columns df.iloc[:3, :2] # Boolean indexing: rows where Age > 25 df[df['Age'] > 25] # Mixed: using iloc to get a single value df.iloc[1, 0] # 'Bob'
.loc) – inclusive end..iloc) – exclusive end.[] operator – for column selection or basic slicing on rows (confusing; prefer .loc/.iloc)..loc[start:stop] includes stop (different from Python lists)..iloc[start:stop] excludes stop (same as Python).
DataFrame (df)
col0 col1 col2
idx0 a 1 x
idx1 b 2 y
idx2 c 3 z
idx3 d 4 w
df.loc['idx0':'idx2', ['col0','col2']] → rows idx0, idx1, idx2 ; cols col0, col2
df.iloc[1:3, 0:2] → rows 1,2 ; cols 0,1
.loc uses labels (inclusive), .iloc uses integer positions (exclusive).
Mastering mathematical operations, head/tail, and indexing/slicing in Pandas is the foundation of efficient data analysis. They let you explore, clean, and transform data with minimal code, leveraging vectorized speed and intuitive syntax. A clear understanding of .loc vs .iloc and automatic index alignment prevents common errors and makes your data workflows robust and readable.
Pandas Series या DataFrame में डेटा लोड करने के बाद, तुरंत कई ज़रूरतें सामने आती हैं:
• त्वरित निरीक्षण: डेटा कैसा दिखता है? पहली कुछ पंक्तियाँ? अंतिम कुछ?
• डेटा निष्कर्षण: एक कॉलम, पंक्तियों की रेंज या विशिष्ट सेल कैसे प्राप्त करें?
• गणना: बिना लूप लिखे पूरे कॉलम या पंक्तियों पर तत्व‑वार अंकगणित (जोड़, गुणा) कैसे करें?
अंतर्निहित विधियों के बिना, आपको मैन्युअल रूप से दोहराना पड़ता, इंडेक्स जाँचनी पड़ती और कस्टम तर्क लिखना पड़ता — धीमा, त्रुटिपूर्ण और पढ़ने में कठिन।
मुख्य समस्या है: सरल, अभिव्यंजक सिंटैक्स का उपयोग करके नामांकित डेटा पर त्वरित अन्वेषण, स्लाइस और गणना कैसे करें।
Pandas इसका समाधान head/tail से पूर्वावलोकन, लचीली अनुक्रमण/स्लाइसिंग (.loc, .iloc, []) और सदिशीकृत गणितीय संक्रियाओं के साथ करता है।
गणितीय संक्रियाएँ: Pandas में, अंकगणितीय ऑपरेटर (+, -, *, /, **, %) Series और DataFrame पर तत्व‑वार काम करते हैं।
संक्रियाएँ index लेबल पर स्वचालित रूप से संरेखित होती हैं। अधिक नियंत्रण के लिए .add(), .mul() जैसी विधियाँ भी हैं।
Head और Tail:
df.head(n) पहली n पंक्तियाँ लौटाता है (डिफ़ॉल्ट 5)।df.tail(n) अंतिम n पंक्तियाँ लौटाता है (डिफ़ॉल्ट 5)।df['कॉलम_नाम'] या df.कॉलम_नाम (एकल कॉलम के लिए)।df.loc[आरंभ:अंत, कॉलम_सूची] — अंतिम लेबल शामिल होता है।df.iloc[आरंभ:अंत, कॉलम_आरंभ:कॉलम_अंत] — अंतिम स्थिति शामिल नहीं (Python स्लाइस जैसी)।df[df['कॉलम'] > मान] किसी शर्त पर पंक्तियाँ फ़िल्टर करता है।एक छोटा DataFrame लें:
import pandas as pd
data = {'नाम':['अमन','बीना','चेतन','डेविड','ईशा'],
'आयु':[25,30,22,35,28],
'अंक':[88,92,75,85,90]}
df = pd.DataFrame(data)
गणितीय संक्रियाएँ:
# हर आयु में 5 जोड़ें (तत्व‑वार) df['आयु'] + 5 # Series: 30,35,27,40,33 # अंक कॉलम दोगुना करें df['अंक'] * 2 # Series: 176,184,150,170,180 # दो कॉलम से नया कॉलम बनाएँ df['कुल'] = df['आयु'] + df['अंक'] # 113,122,97,120,118
Head और Tail:
df.head(3) # पहली 3 पंक्तियाँ df.tail(2) # अंतिम 2 पंक्तियाँ
चयन, अनुक्रमण और स्लाइसिंग:
# कॉलम चयन df['नाम'] # नाम की Series # लेबल‑आधारित स्लाइस: पंक्ति 0 से 2 (सम्मिलित) और कॉलम 'नाम', 'अंक' df.loc[0:2, ['नाम','अंक']] # पूर्णांक‑स्थिति स्लाइस: पहली 3 पंक्तियाँ, पहले 2 कॉलम df.iloc[:3, :2] # बूलियन अनुक्रमण: जहाँ आयु > 25 df[df['आयु'] > 25] # मिश्रित: iloc से एकल मान प्राप्त करना df.iloc[1, 0] # 'बीना'
.loc) — अंतिम सम्मिलित।.iloc) — अंतिम अपवर्जित।[] ऑपरेटर — कॉलम चयन या पंक्तियों पर बुनियादी स्लाइसिंग (भ्रमक; .loc/.iloc पसंद करें)।.loc[प्रारंभ:अंत] अंतिम लेबल शामिल करता है (Python सूचियों से भिन्न)।.iloc[प्रारंभ:अंत] अंतिम अनुक्रमणिका शामिल नहीं करता (Python के समान)।
DataFrame (df)
col0 col1 col2
idx0 a 1 x
idx1 b 2 y
idx2 c 3 z
idx3 d 4 w
df.loc['idx0':'idx2', ['col0','col2']] → पंक्तियाँ idx0, idx1, idx2 ; स्तंभ col0, col2
df.iloc[1:3, 0:2] → पंक्तियाँ 1,2 ; स्तंभ 0,1
.loc लेबल उपयोग करता है (सम्मिलित), .iloc पूर्णांक स्थिति (अपवर्जित)।
Pandas में गणितीय संक्रियाएँ, head/tail और अनुक्रमण/स्लाइसिंग में दक्षता कुशल डेटा विश्लेषण की नींव है। ये न्यूनतम कोड के साथ डेटा का अन्वेषण, सफ़ाई और रूपांतरण करने देते हैं, सदिशीकृत गति और सहज सिंटैक्स का लाभ उठाते हुए। .loc बनाम .iloc और स्वचालित index संरेखण की स्पष्ट समझ सामान्य त्रुटियों को रोकती है और आपके डेटा कार्यप्रवाह को सुदृढ़ और पठनीय बनाती है।
Real‑world data rarely fits into a single column. A student’s record, for example, has a name, age, grade, and city – multiple attributes of different types. A Pandas Series can hold only one column of data; to store a complete table we would need many separate Series and manually keep their row labels aligned, which is messy and error‑prone. The problem is: how to store, manipulate, and analyse two‑dimensional heterogeneous tabular data in a single, easy‑to‑use data structure with labelled rows and columns. The answer is the Pandas DataFrame.
DataFrame : A two‑dimensional, size‑mutable, potentially heterogeneous tabular data structure in Pandas.
It has labelled axes – rows (index) and columns. You can think of it as a spreadsheet or SQL table inside Python.
Each column of a DataFrame is a Series, and all columns share the same row index.
Key difference from Series : A Series is a single labelled column (1D), whereas a DataFrame is a collection of Series aligned along a common index, forming a table (2D).
A DataFrame can have multiple data types – one per column – while a Series is homogeneous.
Create a DataFrame from a dictionary of lists:
import pandas as pd
data = {
'Name': ['Alice', 'Bob', 'Carol'],
'Age': [25, 30, 28],
'Marks': [88.5, 92.0, 76.5]
}
df = pd.DataFrame(data)
print(df)
Output:
Name Age Marks
0 Alice 25 88.5
1 Bob 30 92.0
2 Carol 28 76.5
pd.read_csv(), pd.read_excel(), pd.read_json(), etc..index (rows) and .columns.fillna(), dropna(), and isna() handle NaN values gracefully..shape, .dtypes, .size quickly summarise the DataFrame.
Series DataFrame
-------- -----------
Index Value columns → Name Age Marks
0 10 index ↓
1 20 0 Alice 25 88.5
2 30 1 Bob 30 92.0
(one column) 2 Carol 28 76.5
(multiple columns; each column is a Series)
A Series is a single labelled column. A DataFrame is a collection of Series sharing the same row index.
The DataFrame is the workhorse of data analysis in Python. It extends the idea of a Series from one dimension to two, enabling you to store and manipulate complete tables effortlessly. Understanding how a DataFrame is built from Series – and how the two structures differ – is fundamental to using Pandas effectively. With its rich functionality, the DataFrame forms the bridge between raw data and actionable insights.
products.csv into a DataFrame and display the first 5 rows.वास्तविक दुनिया का डेटा शायद ही कभी एक स्तंभ में फिट बैठता है। एक छात्र के रिकॉर्ड में, उदाहरण के लिए, नाम, आयु, अंक और शहर – भिन्न प्रकार के अनेक गुण होते हैं। एक Pandas Series केवल एक स्तंभ का डेटा रख सकती है; पूरी तालिका संग्रहीत करने के लिए अलग‑अलग Series बनाकर उनके पंक्ति लेबल मैन्युअल रूप से संरेखित करने पड़ते, जो अस्त‑व्यस्त और त्रुटिपूर्ण है। समस्या है: नामांकित पंक्तियों और स्तंभों वाली एकल, उपयोग में सरल डेटा संरचना में द्वि‑आयामी विभिन्न प्रकार के सारणीबद्ध डेटा को कैसे संग्रहीत, हेरफेर और विश्लेषित किया जाए। इसका उत्तर है Pandas DataFrame।
DataFrame : Pandas में एक द्वि‑आयामी, आकार‑परिवर्तनीय, संभावित रूप से विभिन्न प्रकार की सारणीबद्ध डेटा संरचना।
इसके नामांकित अक्ष होते हैं – पंक्तियाँ (index) और स्तंभ (columns)। आप इसे Python के अंदर एक स्प्रेडशीट या SQL तालिका के रूप में सोच सकते हैं।
DataFrame का प्रत्येक स्तंभ एक Series है, और सभी स्तंभ समान पंक्ति index साझा करते हैं।
Series से मुख्य अंतर : एक Series एकल नामांकित स्तंभ (1D) है, जबकि DataFrame एक समान index पर संरेखित Series का संग्रह है, जो एक तालिका (2D) बनाती है।
DataFrame में प्रति स्तंभ अनेक डेटा प्रकार हो सकते हैं; जबकि Series समांग होती है।
सूचियों के शब्दकोश से DataFrame बनाना:
import pandas as pd
data = {
'नाम': ['अमन', 'बीना', 'चेतन'],
'आयु': [25, 30, 28],
'अंक': [88.5, 92.0, 76.5]
}
df = pd.DataFrame(data)
print(df)
आउटपुट:
नाम आयु अंक
0 अमन 25 88.5
1 बीना 30 92.0
2 चेतन 28 76.5
pd.read_csv(), pd.read_excel(), pd.read_json(), आदि।.index (पंक्तियाँ) और .columns (स्तंभ) द्वारा सुलभ।fillna(), dropna(), और isna() जैसी विधियाँ NaN मानों को सहजता से संभालती हैं।.shape, .dtypes, .size DataFrame का त्वरित सारांश देते हैं।
Series DataFrame
-------- -----------
Index मान columns → नाम आयु अंक
0 10 index ↓
1 20 0 अमन 25 88.5
2 30 1 बीना 30 92.0
(एक स्तंभ) 2 चेतन 28 76.5
(अनेक स्तंभ; हर स्तंभ एक Series है)
Series एक नामांकित एकल स्तंभ है। DataFrame समान पंक्ति index साझा करने वाले Series का संग्रह है।
DataFrame, Python में डेटा विश्लेषण का कार्यक्षम घोड़ा है। यह Series के विचार को एक आयाम से दो आयामों तक विस्तारित करता है, जिससे आप संपूर्ण तालिकाओं को सहजता से संग्रहीत और हेरफेर कर सकते हैं। यह समझना कि DataFrame, Series से कैसे बना है और दोनों संरचनाएँ कैसे भिन्न हैं, Pandas का प्रभावी उपयोग करने के लिए मूलभूत है। अपनी समृद्ध कार्यक्षमता के साथ, DataFrame कच्चे डेटा और कार्रवाई योग्य अंतर्दृष्टि के बीच पुल बनाता है।
products.csv को DataFrame में पढ़ें और पहली 5 पंक्तियाँ दिखाएँ।When you have separate columns of data as Pandas Series, or when your data is naturally a list of records (each record being a dictionary), you need a straightforward way to combine them into a single table. Manually aligning indexes or writing loops to merge columns is error‑prone. The core problem is: how to efficiently create a DataFrame from either a dictionary of Series (columns) or a list of dictionaries (rows), while preserving labels and data types correctly. Pandas provides these two fundamental constructors that handle alignment automatically.
DataFrame from a Dictionary of Series: A dictionary where keys become column names and values are Pandas Series (or any array‑like object).
All Series must share the same index, or they will be aligned by label – missing values become NaN.
DataFrame from a List of Dictionaries: A list where each element is a dictionary representing a single row.
The keys of the dictionaries become column names, and the values fill the rows. If a key is missing in a row, the corresponding cell gets NaN.
1. From a Dictionary of Series:
import pandas as pd
names = pd.Series(['Alice', 'Bob', 'Carol'], index=[1,2,3])
ages = pd.Series([25, 30, 22], index=[1,2,3])
scores = pd.Series([88.5, 92.0, 76.5], index=[1,2,3])
df1 = pd.DataFrame({'Name': names, 'Age': ages, 'Score': scores})
print(df1)
Output:
Name Age Score 1 Alice 25 88.5 2 Bob 30 92.0 3 Carol 22 76.5
If indexes differ, alignment happens:
s1 = pd.Series([10, 20], index=['a','b'])
s2 = pd.Series([100, 200], index=['b','c'])
df2 = pd.DataFrame({'col1': s1, 'col2': s2})
print(df2)
col1 col2 a 10.0 NaN b 20.0 100.0 c NaN 200.0
2. From a List of Dictionaries:
data = [
{'Name': 'Alice', 'Age': 25, 'City': 'Delhi'},
{'Name': 'Bob', 'Age': 30, 'City': 'Mumbai'},
{'Name': 'Carol', 'Age': 22} # missing 'City'
]
df3 = pd.DataFrame(data)
print(df3)
Output:
Name Age City
0 Alice 25 Delhi
1 Bob 30 Mumbai
2 Carol 22 NaN
pd.DataFrame(list_of_dicts, index=[...]) sets the row labels.
Input: dict of Series Input: list of dicts
{ 'A': Series([...]), [ {'A':1,'B':2},
'B': Series([...]) } {'A':3,'B':4} ]
| |
v v
+---------------------+ +-------------------+
| DataFrame | | DataFrame |
| index A B | | index A B |
| x a1 b1 | | 0 1 2 |
| y a2 NaN | | 1 3 4 |
+---------------------+ +-------------------+
(alignment on index) (each dict is a row)
Both the dictionary of Series and the list of dictionaries are powerful, intuitive ways to create DataFrames in Pandas. The first is ideal when you already have column‑oriented data as Series, automatically aligning on their indexes. The second is perfect for record‑oriented data commonly found in APIs and JSON. Understanding their behavior — especially alignment and missing data handling — ensures clean, correct DataFrames from the start.
s1 (index 'a','b','c' values 10,20,30) and s2 (index 'b','c','d' values 100,200,300). Build a DataFrame from a dict of these Series. Show the result and explain the NaN entries.[{'x':1, 'y':2}, {'x':5}, {'y':8}]. What are the row and column labels?जब आपके पास Pandas Series के रूप में अलग‑अलग स्तंभ हों, या आपका डेटा स्वाभाविक रूप से रिकॉर्डों की सूची (प्रत्येक रिकॉर्ड एक शब्दकोश) हो, तो आपको उन्हें एक तालिका में जोड़ने का सीधा तरीका चाहिए। मैन्युअल रूप से इंडेक्स संरेखित करना या लूप लिखना त्रुटिपूर्ण है। मुख्य समस्या: Series के शब्दकोश (स्तंभ) या शब्दकोशों की सूची (पंक्तियाँ) से कुशलतापूर्वक DataFrame कैसे बनाया जाए, ताकि लेबल और डेटा प्रकार सही बने रहें। Pandas ये दो मूलभूत निर्माणकर्ता प्रदान करता है जो संरेखण स्वचालित करते हैं।
Series के शब्दकोश से DataFrame: एक शब्दकोश जिसकी कुंजियाँ स्तंभ नाम बनती हैं और मान Pandas Series (या कोई सरणी‑सदृश) होते हैं।
सभी Series समान index साझा करनी चाहिए, अन्यथा लेबल द्वारा संरेखित होंगी – अनुपलब्ध मान NaN बन जाते हैं।
शब्दकोशों की सूची से DataFrame: एक सूची जहाँ प्रत्येक तत्व एक शब्दकोश है जो एक पंक्ति दर्शाता है।
शब्दकोशों की कुंजियाँ स्तंभ नाम बनती हैं, और मान पंक्तियों में भरते हैं। यदि किसी पंक्ति में कुंजी न हो, तो वहाँ NaN आ जाता है।
1. Series के शब्दकोश से:
import pandas as pd
नाम = pd.Series(['अमन', 'बीना', 'चेतन'], index=[1,2,3])
आयु = pd.Series([25, 30, 22], index=[1,2,3])
अंक = pd.Series([88.5, 92.0, 76.5], index=[1,2,3])
df1 = pd.DataFrame({'नाम': नाम, 'आयु': आयु, 'अंक': अंक})
print(df1)
आउटपुट:
नाम आयु अंक 1 अमन 25 88.5 2 बीना 30 92.0 3 चेतन 22 76.5
यदि index भिन्न हों, तो संरेखण होता है:
s1 = pd.Series([10, 20], index=['a','b'])
s2 = pd.Series([100, 200], index=['b','c'])
df2 = pd.DataFrame({'col1': s1, 'col2': s2})
print(df2)
col1 col2 a 10.0 NaN b 20.0 100.0 c NaN 200.0
2. शब्दकोशों की सूची से:
data = [
{'नाम': 'अमन', 'आयु': 25, 'शहर': 'दिल्ली'},
{'नाम': 'बीना', 'आयु': 30, 'शहर': 'मुंबई'},
{'नाम': 'चेतन', 'आयु': 22} # 'शहर' अनुपलब्ध
]
df3 = pd.DataFrame(data)
print(df3)
आउटपुट:
नाम आयु शहर
0 अमन 25 दिल्ली
1 बीना 30 मुंबई
2 चेतन 22 NaN
pd.DataFrame(सूची, index=[...]) पंक्ति लेबल निर्धारित करता है।
इनपुट: Series का शब्दकोश इनपुट: शब्दकोशों की सूची
{ 'A': Series([...]), [ {'A':1,'B':2},
'B': Series([...]) } {'A':3,'B':4} ]
| |
v v
+---------------------+ +-------------------+
| DataFrame | | DataFrame |
| index A B | | index A B |
| x a1 b1 | | 0 1 2 |
| y a2 NaN | | 1 3 4 |
+---------------------+ +-------------------+
(index पर संरेखण) (प्रत्येक शब्दकोश एक पंक्ति)
Series का शब्दकोश और शब्दकोशों की सूची दोनों ही Pandas में DataFrame बनाने के शक्तिशाली, सहज तरीके हैं। पहला तब आदर्श है जब आपके पास स्तंभ‑वार डेटा Series के रूप में हो, जो index पर स्वचालित संरेखित होता है। दूसरा API और JSON में मिलने वाले रिकॉर्ड‑उन्मुख डेटा के लिए उपयुक्त है। इनके व्यवहार — विशेषकर संरेखण और अनुपलब्ध डेटा प्रबंधन — को समझना, आरंभ से ही स्वच्छ, सही DataFrame सुनिश्चित करता है।
s1 (index 'a','b','c' मान 10,20,30) और s2 (index 'b','c','d' मान 100,200,300) बनाएँ। इन Series के शब्दकोश से DataFrame बनाइए। परिणाम दिखाएँ और NaN प्रविष्टियों की व्याख्या करें।[{'x':1, 'y':2}, {'x':5}, {'y':8}]। पंक्ति और स्तंभ लेबल क्या हैं?Data is often stored in plain text files, especially CSV (Comma‑Separated Values). A typical CSV file can contain thousands of rows and multiple columns. Manually opening such files, reading line by line, splitting commas, handling quotes, and dealing with missing values is tedious and error‑prone. The problem is: how to efficiently load a CSV/text file into a structured form, quickly view its contents, and iterate over its rows to process data without writing complex parsing code. Pandas provides simple functions that solve this in a few lines.
Text/CSV File Handling with Pandas : Pandas offers the read_csv() function to read a CSV file and create a DataFrame.
It automatically detects column names, data types, and handles missing values. Once loaded, you can display the data using
head(), tail(), or by printing the DataFrame. To iterate over rows, Pandas provides methods like
iterrows() (returns index and Series per row) and itertuples() (returns namedtuples, faster).
Assume a file students.csv with contents:
name,age,city Alice,25,Delhi Bob,30,Mumbai Carol,22,Pune
Python code:
import pandas as pd
df = pd.read_csv('students.csv')
# display first two rows
print(df.head(2))
# display last row
print(df.tail(1))
# iterate with iterrows
for index, row in df.iterrows():
print(f"{index}: {row['name']} is {row['age']} years old")
# faster iteration with itertuples
for row in df.itertuples():
print(f"{row.Index}: {row.name} - {row.age}")
pd.read_csv() – creates a DataFrame, supports many parameters (delimiter, encoding, header, skiprows, etc.).csv module : csv.reader() or csv.DictReader() for line‑by‑line reading without external libraries.head(), tail(), sample(), or simply print(df).iterrows() – yields (index, Series) pairs, slower but convenient.itertuples() – yields namedtuples, much faster.for value in df['column'] to loop over a single column.pd.read_csv()) loads an entire file into a structured table.head() and tail() give an immediate overview of large files.itertuples() is quite fast for row‑wise processing.read_csv() loads the entire file into memory; may crash for extremely large files.iterrows() is slow because it creates a Series for each row; should not be used for heavy data manipulation.csv module, but chunksize parameter exists.read_csv() always returns a DataFrame with labelled rows and columns.sep parameter.NaN; can specify custom NA strings.iterrows for performance; iteration is meant for small‑scale or row‑specific logic.read_csv(..., chunksize=1000) returns an iterator of DataFrames to process large files in pieces.
CSV File on Disk
|
v
pd.read_csv()
|
v
+-----------------+
| DataFrame (RAM) |
+--------+--------+
|
+--------+----------+
| |
v v
Display Iterate
head()/tail() iterrows() / itertuples()
Reading text/CSV files with Pandas is the first step in any data analysis project. It transforms raw, unstructured files into a clean,
tabular DataFrame. Quick display methods help you verify the content, while iteration methods (especially itertuples()) allow
row‑by‑row processing when necessary. However, always prefer vectorised operations for performance, and be mindful of memory limits when
working with very large files.
products.csv and display its first 8 rows.iterrows(), print each row where the price column is greater than 500.itertuples(). Which one is faster and why?;) as a separator. Show the parameter you would use.iterrows() should be avoided for modifying data inside a loop and suggest a better alternative.डेटा प्रायः सादे टेक्स्ट फ़ाइलों, विशेषकर CSV (कॉमा‑सेपरेटेड वैल्यूज़) में संग्रहीत होता है। एक सामान्य CSV फ़ाइल में हज़ारों पंक्तियाँ और अनेक स्तंभ हो सकते हैं। ऐसी फ़ाइलों को मैन्युअल खोलना, पंक्ति‑दर‑पंक्ति पढ़ना, कॉमा विभाजित करना, उद्धरण चिह्नों को संभालना और अनुपलब्ध मानों से निपटना थकाऊ और त्रुटिपूर्ण है। समस्या है: किसी CSV/टेक्स्ट फ़ाइल को संरचित रूप में कुशलतापूर्वक कैसे लोड करें, उसकी सामग्री को शीघ्रता से देखें और जटिल पार्सिंग कोड लिखे बिना डेटा प्रसंस्करण के लिए पंक्तियों पर पुनरावृत्ति करें। Pandas कुछ पंक्तियों में यह सब हल करने वाले सरल फंक्शन प्रदान करता है।
Pandas के साथ टेक्स्ट/CSV फ़ाइल प्रबंधन : Pandas CSV फ़ाइल पढ़कर DataFrame बनाने के लिए read_csv() फंक्शन प्रदान करता है।
यह स्वचालित रूप से स्तंभ नाम, डेटा प्रकार पहचानता है और अनुपलब्ध मानों को संभालता है। एक बार लोड होने पर, head(), tail()
या DataFrame को प्रिंट करके प्रदर्शित कर सकते हैं। पंक्तियों पर पुनरावृत्ति करने के लिए,
iterrows() (प्रति पंक्ति index और Series देता है) और itertuples() (namedtuples देता है, तेज़) जैसी विधियाँ हैं।
मान लीजिए students.csv फ़ाइल में यह सामग्री है:
नाम,आयु,शहर अमन,25,दिल्ली बीना,30,मुंबई चेतन,22,पुणे
Python कोड:
import pandas as pd
df = pd.read_csv('students.csv')
# पहली दो पंक्तियाँ दिखाएँ
print(df.head(2))
# अंतिम पंक्ति दिखाएँ
print(df.tail(1))
# iterrows से पुनरावृत्ति
for index, row in df.iterrows():
print(f"{index}: {row['नाम']} की आयु {row['आयु']} वर्ष है")
# itertuples से तेज़ पुनरावृत्ति
for row in df.itertuples():
print(f"{row.Index}: {row.नाम} - {row.आयु}")
pd.read_csv() – DataFrame बनाता है, कई पैरामीटर समर्थित (डेलिमिटर, एन्कोडिंग, हेडर, skiprows आदि)।csv मॉड्यूल द्वारा : csv.reader() या csv.DictReader() बिना बाहरी लाइब्रेरी के पंक्ति‑दर‑पंक्ति पढ़ने के लिए।head(), tail(), sample(), या सीधे print(df)।iterrows() – (index, Series) युग्म देता है, धीमा किंतु सुविधाजनक।itertuples() – namedtuples देता है, अधिक तेज़।for value in df['column'] एकल स्तंभ पर लूप।pd.read_csv()) पूरी फ़ाइल को संरचित तालिका में लोड करती है।head() और tail() बड़ी फ़ाइलों का तुरंत अवलोकन देते हैं।itertuples() पंक्ति‑वार प्रसंस्करण के लिए काफी तेज़ है।read_csv() पूरी फ़ाइल को मेमोरी में लोड करता है; अत्यधिक बड़ी फ़ाइलों पर क्रैश हो सकता है।iterrows() धीमा है क्योंकि यह हर पंक्ति के लिए Series बनाता है; भारी डेटा हेरफेर के लिए उपयुक्त नहीं।csv मॉड्यूल जितनी आसानी से खंडित पठन का समर्थन नहीं करता, परंतु chunksize पैरामीटर मौजूद है।read_csv() हमेशा नामांकित पंक्तियों और स्तंभों वाला DataFrame लौटाता है।sep पैरामीटर द्वारा कोई भी कस्टम विभाजक।NaN में बदलता है; कस्टम NA स्ट्रिंग निर्दिष्ट कर सकते हैं।iterrows की जगह सदिशीकृत संक्रियाएँ पसंद की जाती हैं; पुनरावृत्ति छोटे पैमाने या पंक्ति‑विशिष्ट तर्क के लिए है।read_csv(..., chunksize=1000) बड़ी फ़ाइलों को टुकड़ों में प्रोसेस करने के लिए DataFrame का इटरेटर लौटाता है।
डिस्क पर CSV फ़ाइल
|
v
pd.read_csv()
|
v
+-----------------+
| DataFrame (RAM) |
+--------+--------+
|
+--------+----------+
| |
v v
प्रदर्शन पुनरावृत्ति
head()/tail() iterrows() / itertuples()
Pandas के साथ टेक्स्ट/CSV फ़ाइलें पढ़ना किसी भी डेटा विश्लेषण परियोजना का पहला कदम है। यह कच्ची, असंरचित फ़ाइलों को एक स्वच्छ,
सारणीबद्ध DataFrame में बदलता है। त्वरित प्रदर्शन विधियाँ सामग्री सत्यापित करने में मदद करती हैं, जबकि पुनरावृत्ति विधियाँ
(विशेषकर itertuples()) आवश्यकता पड़ने पर पंक्ति‑दर‑पंक्ति प्रसंस्करण की अनुमति देती हैं। फिर भी, प्रदर्शन के लिए
हमेशा सदिशीकृत संक्रियाएँ पसंद करें और बहुत बड़ी फ़ाइलों के साथ काम करते समय मेमोरी सीमाओं का ध्यान रखें।
products.csv पढ़ने और उसकी पहली 8 पंक्तियाँ प्रदर्शित करने का प्रोग्राम लिखिए।iterrows() का उपयोग करते हुए, वह पंक्तियाँ मुद्रित करें जहाँ मूल्य स्तंभ 500 से अधिक हो।itertuples() में बदलें। कौन सा तेज़ है और क्यों?;) विभाजक का उपयोग करती है। वह पैरामीटर बताइए जो आप उपयोग करेंगे।iterrows() से क्यों बचना चाहिए और एक बेहतर विकल्प सुझाइए।After loading a dataset into a DataFrame, you rarely keep it in its original form. You often need to add new columns (e.g., computed fields), select a subset of rows or columns for analysis, delete unwanted or irrelevant data, or rename columns to more meaningful labels. Doing these tasks with basic Python loops is inefficient and breaks the tabular structure. The core problem is: how to perform these everyday structural manipulations directly on a DataFrame using simple, expressive commands. Pandas provides dedicated methods that preserve data alignment and are optimized for speed.
These are the fundamental row/column operations in Pandas DataFrames:
df['new_col'].df[['col1','col2']] for columns, df.loc[] / df.iloc[] for rows and subsets, or boolean indexing for conditions.df.drop() to remove specified rows (by index) or columns (by name). The axis parameter controls whether to drop rows (axis=0) or columns (axis=1). Alternatively, del df['col'] deletes a column in‑place.df.rename() with a dictionary mapping old names to new names. Can also rename index labels.
import pandas as pd
df = pd.DataFrame({
'Name': ['Alice','Bob','Carol'],
'Age': [25,30,22],
'Score':[88,92,75]
})
# ----- ADD a new column -----
df['Grade'] = ['A','A','B'] # from a list
df['Bonus'] = df['Score'] * 0.1 # computed
# ----- SELECT columns and rows -----
print(df[['Name','Grade']]) # two columns
print(df.loc[0:1, :]) # first two rows, all columns
print(df[df['Age'] > 25]) # rows where Age > 25
# ----- DELETE a column -----
df.drop('Bonus', axis=1, inplace=True) # delete column
# or: del df['Bonus']
# ----- DELETE a row -----
df.drop(index=1, inplace=True) # removes Bob (row with index 1)
# ----- RENAME columns -----
df.rename(columns={'Name':'Student','Score':'Marks'}, inplace=True)
print(df)
df.insert(loc, column, value) to place at a specific position.df.filter() for selecting columns by name pattern.drop() with axis, del, or pop() (removes and returns a column).rename() with columns/index mapper, df.columns = ['new','names'] to replace all column names, or df.set_axis().drop() returns a new DataFrame by default, preserving the original unless inplace=True.inplace=True or not assigning the result leads to unintended loss of changes.df[df['Age']>25]['Name'] = 'X') may not modify the original DataFrame; use .loc for correct updates.drop() with inplace=False creates a full copy; on huge DataFrames this may be inefficient.insert() is limited to single column at a time; adding multiple columns at specific positions requires extra steps.drop(), axis=0 for rows, axis=1 for columns.rename() returns a new DataFrame; use inplace=True to modify existing.del : Works only for columns, not rows, and modifies in‑place immediately.DataFrame +------------------------------------------+ | ADD | SELECT | DELETE | RENAME | +------------+-------------+--------+--------+ | df['col'] | df[['c1']] | drop() | rename() | insert() | .loc/.iloc | del | columns= | assign() | boolean | pop() | set_axis() +------------+-------------+--------+--------+
Mastering add, select, delete, and rename operations is essential for data cleaning and preparation in Pandas. They allow you to shape your DataFrame exactly the way you need without leaving the Python environment. Using these methods consistently – and being aware of copy vs in‑place behaviour – ensures clean, efficient, and bug‑free data workflows.
df.drop(index=2) and df.drop(columns='A'). What does axis control?insert().DataFrame में डेटा लोड करने के बाद, आप शायद ही कभी इसे मूल रूप में रखते हैं। अक्सर आपको नए स्तंभ जोड़ने (जैसे परिकलित फ़ील्ड), विश्लेषण के लिए पंक्तियों या स्तंभों का उपसमुच्चय चुनने, अनावश्यक डेटा हटाने, या स्तंभों के अधिक अर्थपूर्ण नाम रखने की आवश्यकता होती है। बुनियादी Python लूप के साथ ये कार्य करना अक्षम है और सारणीबद्ध संरचना को तोड़ता है। मुख्य समस्या है: सरल, अभिव्यंजक कमांड का उपयोग करके इन रोज़मर्रा के संरचनात्मक हेरफेरों को सीधे DataFrame पर कैसे किया जाए। Pandas समर्पित विधियाँ प्रदान करता है जो डेटा संरेखण बनाए रखती हैं और गति के लिए अनुकूलित होती हैं।
Pandas DataFrame में ये मूल पंक्ति/स्तंभ संक्रियाएँ हैं:
df['नया_स्तंभ'] पर एक स्केलर, सूची, Series या अभिव्यक्ति का परिणाम निर्दिष्ट करके नया स्तंभ बनाएँ।df[['col1','col2']], पंक्तियों और उपसमुच्चय के लिए df.loc[] / df.iloc[], या शर्तों के लिए बूलियन अनुक्रमण।df.drop() से निर्दिष्ट पंक्तियाँ (index द्वारा) या स्तंभ (नाम से) हटाएँ। axis पैरामीटर नियंत्रित करता है (axis=0 पंक्तियाँ, axis=1 स्तंभ)। del df['col'] से भी स्तंभ हटाया जा सकता है।df.rename() के साथ पुराने नामों से नए नामों का शब्दकोश दें। index लेबल भी बदल सकते हैं।
import pandas as pd
df = pd.DataFrame({
'नाम': ['अमन','बीना','चेतन'],
'आयु': [25,30,22],
'अंक': [88,92,75]
})
# ----- स्तंभ जोड़ें -----
df['ग्रेड'] = ['A','A','B'] # सूची से
df['बोनस'] = df['अंक'] * 0.1 # परिकलित
# ----- स्तंभ और पंक्तियाँ चुनें -----
print(df[['नाम','ग्रेड']]) # दो स्तंभ
print(df.loc[0:1, :]) # पहली दो पंक्तियाँ, सभी स्तंभ
print(df[df['आयु'] > 25]) # जहाँ आयु > 25
# ----- स्तंभ हटाएँ -----
df.drop('बोनस', axis=1, inplace=True) # स्तंभ हटाएँ
# या: del df['बोनस']
# ----- पंक्ति हटाएँ -----
df.drop(index=1, inplace=True) # बीना (index 1) हटाएँ
# ----- नाम बदलें -----
df.rename(columns={'नाम':'छात्र','अंक':'प्राप्तांक'}, inplace=True)
print(df)
df.insert(loc, column, value) विशिष्ट स्थान पर रखने के लिए।df.filter()।drop() axis के साथ, del, या pop() (स्तंभ हटाता है और लौटाता है)।rename() columns/index मानचित्र के साथ, सभी स्तंभ नाम बदलने के लिए df.columns = ['नए','नाम'], या df.set_axis()।drop() डिफ़ॉल्ट रूप से नया DataFrame लौटाता है, जब तक inplace=True न हो, मूल सुरक्षित रहता है।inplace=True भूल जाने या परिणाम निर्दिष्ट न करने से परिवर्तन खो सकते हैं।df[df['Age']>25]['Name'] = 'X') मूल DataFrame को संशोधित नहीं कर सकता; सही अद्यतन के लिए .loc उपयोग करें।inplace=False के साथ drop() पूरी प्रतिलिपि बनाता है; विशाल DataFrame पर यह अक्षम हो सकता है।insert() एक बार में केवल एक स्तंभ तक सीमित; विशिष्ट स्थानों पर कई स्तंभ जोड़ने के लिए अतिरिक्त चरण चाहिए।drop() में, axis=0 पंक्तियाँ, axis=1 स्तंभ।rename() नया DataFrame लौटाता है; मौजूदा बदलने के लिए inplace=True उपयोग करें।del से हटाना : केवल स्तंभों के लिए काम करता है, पंक्तियों के लिए नहीं, और तुरंत सीधे बदलता है।DataFrame +------------------------------------------+ | जोड़ें | चुनें | हटाएँ | नाम बदलें | +------------+-------------+--------+--------+ | df['col'] | df[['c1']] | drop() | rename() | insert() | .loc/.iloc | del | columns= | assign() | boolean | pop() | set_axis() +------------+-------------+--------+--------+
Pandas में जोड़ने, चुनने, हटाने और नाम बदलने की संक्रियाओं में निपुणता डेटा सफ़ाई और तैयारी के लिए आवश्यक है। ये आपको अपने DataFrame को बिल्कुल वैसे आकार देने देती हैं जैसा आपको चाहिए, Python परिवेश छोड़े बिना। इन विधियों का लगातार उपयोग – और प्रतिलिपि बनाम इन‑प्लेस व्यवहार के प्रति जागरूकता – स्वच्छ, कुशल और त्रुटि‑मुक्त डेटा कार्यप्रवाह सुनिश्चित करता है।
df.drop(index=2) और df.drop(columns='A') में अंतर समझाइए। axis क्या नियंत्रित करता है?insert() का उपयोग करके स्थान 0 (पहला स्तंभ) पर नया स्तंभ जोड़े।Once a large DataFrame is created (e.g., from a CSV), you rarely need to see all rows at once. You want a quick peek at the top or bottom to verify structure, data types, and sample values. Later, you need to extract specific rows based on meaningful row labels (like dates or IDs) or filter rows that satisfy a logical condition (e.g., all products with price > 500). Doing this without built‑in methods means writing manual loops and comparisons, which is slow and clutters the code. The problem is: how to quickly preview data and precisely select rows using labels or logical conditions without sacrificing readability and speed.
head(n) : Returns the first n rows (default 5). Used for quick inspection of the top of the DataFrame.
tail(n) : Returns the last n rows (default 5). Useful to check the end of a dataset, especially ordered data.
Label‑based Indexing : Selecting rows and columns using their actual index and column names.
The primary tool is .loc[]: df.loc[row_labels, column_labels]. It is inclusive on both sides when slicing.
The direct [] operator on a DataFrame can also accept a single label (returns a column), but for rows you should use .loc.
Boolean Indexing : Filtering rows by providing a boolean Series (or list) of the same length as the DataFrame.
Typically written as df[condition], e.g., df[df['age'] > 18]. The condition is evaluated element‑wise, and only rows where the result is True are kept.
import pandas as pd
# Sample DataFrame
df = pd.DataFrame({
'Name': ['Alice','Bob','Carol','Dave','Eve'],
'Age': [25, 30, 22, 35, 28],
'Score': [88, 92, 75, 85, 90]
}, index=['a','b','c','d','e']) # custom index labels
# ---- Head and Tail ----
print("First 3 rows:\n", df.head(3))
print("Last 2 rows:\n", df.tail(2))
# ---- Label‑based Indexing with .loc ----
print("Row with label 'c':\n", df.loc['c']) # single row as Series
print("Rows from 'b' to 'd':\n", df.loc['b':'d']) # slice includes 'd'
print("Specific columns for those rows:\n", df.loc['b':'d', ['Name','Score']])
# ---- Boolean Indexing ----
# All rows where Age > 25
print("Age > 25:\n", df[df['Age'] > 25])
# Combined condition: Age > 25 AND Score > 85
print("Age > 25 and Score > 85:\n", df[(df['Age'] > 25) & (df['Score'] > 85)])
head(n) – first n rows.tail(n) – last n rows..loc[] – primary method. Accepts single label, list of labels, label slices (inclusive), and boolean arrays.df['column_name'] or df.column_name (attribute style, if name is a valid identifier).df['a'] (that would look for column 'a'); use .loc.df[df['col'] > value]& (and), | (or), ~ (not). Use parentheses around each condition..isin(): df[df['col'].isin(['A','B'])].loc[]: df.loc[df['Age'] > 25, 'Name']head() and tail() give immediate insight into the data without printing entire tables.df[df['Score'] > 90] reads almost like English..loc lets you pick exact rows/columns by name, irrespective of integer position..loc includes the stop label, which is intuitive for time‑series data with date/time indices.&/| operators can become messy.df[1] tries to select a column named 1, not row 1; new users accidentally use integer position instead of .loc..loc['a':'c'] includes 'c', unlike Python lists; this can cause off‑by‑one errors when mixed with .iloc.& (and), | (or), ~ (not), not the Python and/or keywords..loc works with MultiIndex (hierarchical) labels using tuples.query(): An alternative for complex boolean expressions: df.query('Age > 25 and Score < 90') – often cleaner.DataFrame (10 rows) +----------------------------+ | head(3) → first 3 rows | | tail(2) → last 2 rows | +----------------------------+ Label‑based indexing with .loc: df.loc['b':'d', ['Name','Score']] → rows with labels b, c, d (inclusive); columns Name and Score Boolean indexing: df[df['Age'] > 25] → Only rows where Age column value > 25
head() and tail() are your first checkpoint when exploring any dataset – they instantly reveal data structure and potential issues.
Label‑based indexing with .loc gives precise control over rows and columns using meaningful names, while boolean indexing filters rows
with logical conditions in a clean, vectorised way. Mastering these three techniques is fundamental to efficient data exploration and cleaning in Pandas.
head() and tail() to display the first 4 and last 3 rows..loc to retrieve the row for a specific name..loc to select a slice of rows from one name to another and only two columns.df['a'] might not give the row with label 'a' but instead a column named 'a'. How do you correctly get the row?.query() that replicates a boolean indexing condition of your choice.जब एक बड़ा DataFrame बन जाता है (जैसे CSV से), तो शायद ही कभी सारी पंक्तियाँ एक साथ देखनी पड़ें। आप ऊपर या नीचे की कुछ पंक्तियाँ देखकर संरचना, डेटा प्रकार और नमूना मान सत्यापित करना चाहते हैं। बाद में, आपको सार्थक पंक्ति लेबल (जैसे दिनांक या ID) के आधार पर विशिष्ट पंक्तियाँ निकालनी होती हैं या किसी तार्किक शर्त (जैसे सभी उत्पाद जिनका मूल्य > 500) को संतुष्ट करने वाली पंक्तियाँ फ़िल्टर करनी होती हैं। अंतर्निहित विधियों के बिना ऐसा करने के लिए मैन्युअल लूप और तुलना लिखनी पड़ती है, जो धीमा और कोड को अव्यवस्थित करता है। समस्या है: पठनीयता और गति खोए बिना, डेटा का त्वरित पूर्वावलोकन कैसे करें और लेबल या तार्किक शर्तों द्वारा पंक्तियाँ सटीकता से कैसे चुनें।
head(n) : DataFrame की पहली n पंक्तियाँ लौटाता है (डिफ़ॉल्ट 5)। डेटा के ऊपरी हिस्से का त्वरित निरीक्षण करने के लिए।
tail(n) : अंतिम n पंक्तियाँ लौटाता है (डिफ़ॉल्ट 5)। विशेषकर क्रमित डेटा के अंत की जाँच के लिए उपयोगी।
लेबल‑आधारित अनुक्रमण (Label‑based Indexing) : वास्तविक index और स्तंभ नामों का उपयोग करके पंक्तियाँ और स्तंभ चुनना।
प्रमुख उपकरण है .loc[]: df.loc[पंक्ति_लेबल, स्तंभ_लेबल]। स्लाइस करते समय आरंभ और अंत दोनों शामिल रहते हैं।
DataFrame पर सीधा [] ऑपरेटर एकल लेबल लेकर स्तंभ लौटा सकता है, परंतु पंक्तियों के लिए .loc का प्रयोग करना चाहिए।
बूलियन अनुक्रमण (Boolean Indexing) : एक बूलियन Series (या सूची) प्रदान करके पंक्तियाँ फ़िल्टर करना जिसकी लंबाई DataFrame के बराबर हो।
सामान्यतः df[शर्त] के रूप में लिखा जाता है, जैसे df[df['आयु'] > 18]। शर्त तत्व‑वार मूल्यांकित होती है और केवल True वाली पंक्तियाँ रखी जाती हैं।
import pandas as pd
# नमूना DataFrame
df = pd.DataFrame({
'नाम': ['अमन','बीना','चेतन','डेविड','ईशा'],
'आयु': [25, 30, 22, 35, 28],
'अंक': [88, 92, 75, 85, 90]
}, index=['a','b','c','d','e']) # कस्टम index लेबल
# ---- Head और Tail ----
print("पहली 3 पंक्तियाँ:\n", df.head(3))
print("अंतिम 2 पंक्तियाँ:\n", df.tail(2))
# ---- लेबल‑आधारित अनुक्रमण .loc के साथ ----
print("लेबल 'c' वाली पंक्ति:\n", df.loc['c']) # एकल पंक्ति Series के रूप में
print("'b' से 'd' तक की पंक्तियाँ:\n", df.loc['b':'d']) # स्लाइस में 'd' शामिल
print("उन पंक्तियों के लिए विशेष स्तंभ:\n", df.loc['b':'d', ['नाम','अंक']])
# ---- बूलियन अनुक्रमण ----
# सभी पंक्तियाँ जहाँ आयु > 25
print("आयु > 25:\n", df[df['आयु'] > 25])
# संयुक्त शर्त: आयु > 25 और अंक > 85
print("आयु > 25 और अंक > 85:\n", df[(df['आयु'] > 25) & (df['अंक'] > 85)])
head(n) – पहली n पंक्तियाँ।tail(n) – अंतिम n पंक्तियाँ।.loc[] – प्रमुख विधि। एकल लेबल, लेबलों की सूची, लेबल स्लाइस (सम्मिलित), और बूलियन सरणियाँ स्वीकार करता है।df['स्तंभ_नाम'] या df.स्तंभ_नाम (यदि नाम वैध पहचानकर्ता हो)।df['a'] स्तंभ 'a' खोजेगा; सही तरीका है .loc।df[df['col'] > मान]& (और), | (या), ~ (नहीं) से जोड़ें। हर शर्त को कोष्ठक में रखें।.isin() का उपयोग: df[df['col'].isin(['A','B'])].loc[] के अंदर भी: df.loc[df['आयु'] > 25, 'नाम']head() और tail() बिना पूरी तालिका छापे डेटा में तत्काल अंतर्दृष्टि देते हैं।df[df['अंक'] > 90] लगभग अंग्रेज़ी जैसा पढ़ा जाता है।.loc आपको पूर्णांक स्थिति की चिंता किए बिना नाम से सटीक पंक्तियाँ/स्तंभ चुनने देता है।.loc अंतिम लेबल शामिल करता है, जो दिनांक/समय index वाले डेटा के लिए सहज है।&/| ऑपरेटर अव्यवस्थित हो सकते हैं।df[1] स्तंभ '1' ढूँढता है, पंक्ति नहीं; नए उपयोगकर्ता गलती से पूर्णांक स्थिति का प्रयोग करते हैं।.loc['a':'c'] 'c' को शामिल करता है, Python सूचियों के विपरीत; .iloc के साथ मिलाने पर एक‑कम त्रुटियाँ हो सकती हैं।& (और), | (या), ~ (नहीं); Python के and/or कीवर्ड नहीं।.loc पदानुक्रमित लेबलों के साथ टपल का उपयोग करके काम करता है।query() से पठनीयता: जटिल बूलियन अभिव्यक्तियों के लिए वैकल्पिक: df.query('आयु > 25 and अंक < 90') – अक्सर साफ़‑सुथरा।DataFrame (10 पंक्तियाँ) +----------------------------+ | head(3) → पहली 3 पंक्तियाँ | | tail(2) → अंतिम 2 पंक्तियाँ| +----------------------------+ लेबल‑आधारित अनुक्रमण .loc के साथ: df.loc['b':'d', ['नाम','अंक']] → लेबल b, c, d (सम्मिलित) वाली पंक्तियाँ; स्तंभ नाम और अंक बूलियन अनुक्रमण: df[df['आयु'] > 25] → केवल वे पंक्तियाँ जहाँ आयु स्तंभ का मान > 25
किसी भी डेटासेट की खोज करते समय head() और tail() आपका पहला जाँच बिंदु हैं – ये तुरंत डेटा संरचना और संभावित समस्याएँ दिखाते हैं।
.loc के साथ लेबल‑आधारित अनुक्रमण अर्थपूर्ण नामों द्वारा पंक्तियों और स्तंभों पर सटीक नियंत्रण देता है, जबकि बूलियन अनुक्रमण
स्वच्छ, सदिशीकृत तरीके से तार्किक शर्तों के साथ पंक्तियाँ फ़िल्टर करता है। इन तीन तकनीकों में निपुणता Pandas में कुशल डेटा अन्वेषण और सफ़ाई की नींव है।
head() और tail() का उपयोग करें।.loc का प्रयोग करें।.loc से एक नाम से दूसरे नाम तक की पंक्तियों का स्लाइस चुनें और केवल दो स्तंभ लें।df['a'] पंक्ति लेबल 'a' के बजाय स्तंभ 'a' क्यों देता है। पंक्ति पाने का सही तरीका क्या है?.query() का उपयोग करते हुए लिखें।In real‑world projects, data rarely originates inside Python. It often lives in CSV (Comma‑Separated Values) files exported from spreadsheets, databases, or web applications. Analysts need to bring this data into a Pandas DataFrame for cleaning, transformation, and visualisation. After processing, the results must be saved back to a CSV file for sharing or archival. The problem is: how to reliably move tabular data between external CSV files and Pandas DataFrames without losing structure, data types, or encountering parsing errors.
Importing (Reading) : pandas.read_csv() is the primary function. It reads a CSV file from a given path and returns a DataFrame.
It automatically detects the separator, infers column names from the first row, and attempts to convert data to appropriate types.
Important parameters include filepath, sep, header, index_col, usecols, dtype, and na_values.
Exporting (Writing) : DataFrame.to_csv() writes the DataFrame to a CSV file. Common parameters are path, sep,
index (whether to write row labels), header (whether to write column names), and columns to select a subset.
import pandas as pd
# ----- Import (Read) -----
df = pd.read_csv('employees.csv') # default sep=','
df = pd.read_csv('data.tsv', sep='\t') # tab-separated
df = pd.read_csv('no_header.csv', header=None) # no header row
df = pd.read_csv('data.csv', usecols=['Name','Age']) # read only specific columns
df = pd.read_csv('data.csv', dtype={'Age': int}) # enforce data types
df = pd.read_csv('data.csv', index_col='ID') # set column as row index
# ----- Export (Write) -----
df.to_csv('output.csv', index=False) # don't save row indices
df.to_csv('output.tsv', sep='\t') # tab separator
df.to_csv('subset.csv', columns=['Name','Salary']) # write only certain columns
df.to_csv('no_header_out.csv', header=False) # omit column names
pd.read_csv() (comma), pd.read_table() (generic separator, default tab).pd.read_csv('big.csv', chunksize=1000) returns an iterator of DataFrames.to_csv() with compression (compression='gzip'), different encoding (encoding='utf-8'), or appending mode (mode='a').csv module for simple line‑by‑line processing, but then manual conversion to DataFrame is needed.to_csv() makes sharing with Excel, databases, and other tools seamless.chunksize.)encoding is explicitly specified.to_csv() silently overwrites existing files; caution is needed.sep=',').header=0). header=None for files without a header.index_col allows using an existing column.NaN; custom NA strings can be set via na_values.to_csv() writes the row index; use index=False to suppress it.df.to_csv('out.csv', index=False) followed by pd.read_csv('out.csv') reproduces the same data (types may vary slightly).
CSV File DataFrame
+-------------+ +-----------------+
| students.csv| read_csv | Name Age Mark |
+-------------+ --------> +-----------------+
| Alice,25,88 | | Alice 25 88 |
| Bob,30,92 | | Bob 30 92 |
+-------------+ +-----------------+
|
to_csv |
v
+-------------+
| output.csv |
+-------------+
Seamless import and export between CSV files and DataFrames is a cornerstone of data analysis with Python.
read_csv() and to_csv() provide a robust, customisable bridge between external data sources and the powerful Pandas ecosystem.
Understanding the key parameters (separator, header, index, encoding) ensures smooth data ingestion and reliable output, saving time and avoiding common pitfalls.
sales.csv into a DataFrame. Print the number of rows and columns.data.tsv using the appropriate parameter.inventory.csv.df.to_csv('output.csv', index=False) is preferred when sharing data with others.वास्तविक परियोजनाओं में, डेटा शायद ही कभी Python के अंदर उत्पन्न होता है। यह अक्सर स्प्रेडशीट, डेटाबेस या वेब अनुप्रयोगों से निर्यात की गई CSV (कॉमा‑सेपरेटेड वैल्यूज़) फ़ाइलों में रहता है। विश्लेषकों को सफाई, रूपांतरण और दृश्यीकरण के लिए इस डेटा को Pandas DataFrame में लाना होता है। प्रसंस्करण के बाद, परिणामों को साझा करने या संग्रहित करने के लिए CSV फ़ाइल में वापस सहेजना होता है। समस्या है: संरचना, डेटा प्रकार खोए बिना या पार्सिंग त्रुटियों का सामना किए बिना बाहरी CSV फ़ाइलों और Pandas DataFrames के बीच सारणीबद्ध डेटा को विश्वसनीय ढंग से कैसे स्थानांतरित किया जाए।
आयात (पढ़ना) : pandas.read_csv() मुख्य फंक्शन है। यह दिए गए पथ से CSV फ़ाइल पढ़ता है और DataFrame लौटाता है।
यह स्वचालित रूप से विभाजक पहचानता है, पहली पंक्ति से स्तंभ नाम लेता है और डेटा को उपयुक्त प्रकारों में बदलने का प्रयास करता है।
महत्वपूर्ण पैरामीटर: filepath, sep, header, index_col, usecols, dtype, और na_values।
निर्यात (लिखना) : DataFrame.to_csv() DataFrame को CSV फ़ाइल में लिखता है। सामान्य पैरामीटर: path, sep,
index (पंक्ति लेबल लिखें या नहीं), header (स्तंभ नाम लिखें या नहीं), और columns उपसमुच्चय चुनने के लिए।
import pandas as pd
# ----- आयात (पढ़ें) -----
df = pd.read_csv('employees.csv') # डिफ़ॉल्ट sep=','
df = pd.read_csv('data.tsv', sep='\t') # टैब‑विभाजित
df = pd.read_csv('no_header.csv', header=None) # कोई हेडर पंक्ति नहीं
df = pd.read_csv('data.csv', usecols=['Name','Age']) # केवल कुछ स्तंभ पढ़ें
df = pd.read_csv('data.csv', dtype={'Age': int}) # डेटा प्रकार निर्धारित करें
df = pd.read_csv('data.csv', index_col='ID') # किसी स्तंभ को पंक्ति index बनाएँ
# ----- निर्यात (लिखें) -----
df.to_csv('output.csv', index=False) # पंक्ति index न लिखें
df.to_csv('output.tsv', sep='\t') # टैब विभाजक
df.to_csv('subset.csv', columns=['Name','Salary']) # केवल कुछ स्तंभ लिखें
df.to_csv('no_header_out.csv', header=False) # स्तंभ नाम हटाएँ
pd.read_csv() (कॉमा), pd.read_table() (सामान्य विभाजक, डिफ़ॉल्ट टैब)।pd.read_csv('big.csv', chunksize=1000) DataFrame का इटरेटर लौटाता है।to_csv() संपीड़न (compression='gzip'), भिन्न एन्कोडिंग (encoding='utf-8'), या जोड़ने के मोड (mode='a') के साथ।csv मॉड्यूल का उपयोग सरल पंक्ति‑दर‑पंक्ति प्रसंस्करण के लिए, लेकिन फिर DataFrame में मैन्युअल रूपांतरण करना पड़ता है।to_csv() Excel, डेटाबेस और अन्य उपकरणों के साथ सहज साझाकरण बनाता है।chunksize का उपयोग करें।)encoding स्पष्ट न किया जाए।to_csv() मौजूदा फ़ाइलों को चुपचाप ओवरराइट करता है; सावधानी आवश्यक है।sep=',')।header=0)। बिना हेडर वाली फ़ाइलों के लिए header=None।index_col किसी मौजूदा स्तंभ का उपयोग करने देता है।NaN में बदलते हैं; na_values द्वारा कस्टम NA स्ट्रिंग सेट की जा सकती हैं।to_csv() पंक्ति index लिखता है; index=False से हटाएँ।df.to_csv('out.csv', index=False) फिर pd.read_csv('out.csv') वही डेटा पुनरुत्पादित करता है (प्रकार थोड़े भिन्न हो सकते हैं)।
CSV फ़ाइल DataFrame
+-------------+ +-----------------+
| students.csv| read_csv | नाम आयु अंक |
+-------------+ --------> +-----------------+
| अमन,25,88 | | अमन 25 88 |
| बीना,30,92 | | बीना 30 92 |
+-------------+ +-----------------+
|
to_csv |
v
+-------------+
| output.csv |
+-------------+
CSV फ़ाइलों और DataFrames के बीच सहज आयात/निर्यात, Python के साथ डेटा विश्लेषण की आधारशिला है।
read_csv() और to_csv() बाहरी डेटा स्रोतों और शक्तिशाली Pandas पारिस्थितिकी तंत्र के बीच एक मज़बूत, अनुकूलन योग्य पुल प्रदान करते हैं।
प्रमुख पैरामीटरों (विभाजक, हेडर, index, एन्कोडिंग) को समझना सुगम डेटा अंतर्ग्रहण और विश्वसनीय आउटपुट सुनिश्चित करता है, समय बचाता है और सामान्य जाल से बचाता है।
sales.csv फ़ाइल पढ़कर DataFrame बनाएँ। पंक्तियों और स्तंभों की संख्या मुद्रित करें।data.tsv को उपयुक्त पैरामीटर के साथ पढ़ें।inventory.csv से केवल 'product' और 'price' स्तंभ पढ़ें।df.to_csv('output.csv', index=False) क्यों पसंद किया जाता है।Data scientists and analysts often work with massive datasets containing thousands or millions of rows. Raw numbers in tables or summary statistics alone cannot easily reveal trends, patterns, outliers, or correlations. For example, a table of monthly sales figures across 50 cities makes it nearly impossible to quickly spot which regions are underperforming or how sales change over time. The core problem is: how can we transform complex, multidimensional data into an understandable and actionable visual form that reveals insights at a glance? Data visualization addresses exactly this gap.
Data Visualization : The graphical representation of information and data. It uses visual elements like charts, graphs, maps, and plots to communicate data relationships, patterns, and trends clearly and efficiently. In data science, it is a critical step for exploratory data analysis (EDA), model interpretation, and communicating results to stakeholders. It turns abstract numbers into visual context, making the invisible visible.
• Line chart : Shows the trend of a company's stock price over the past year — an upward or downward slope is instantly recognizable.
• Bar chart : Compares sales of different products; the tallest bar immediately identifies the best-selling product.
• Scatter plot : Reveals relationship between advertising spend and revenue; points clustering along a diagonal line suggest correlation.
• Heatmap : Displays correlation matrix of multiple variables with color intensity, quickly highlighting strong positive or negative relationships.
Raw Data → Cleaning → Exploration (Visuals) → Modeling → Interpretation (Visuals) → Communication
| | | |
v v v v
(histograms, boxplots) (scatter, heatmap) (residual plots) (dashboards, reports)
Visualization is not a separate step; it is embedded throughout the data science pipeline.
Data visualization is not just about making pretty charts; it is a core component of the data science workflow. It helps uncover hidden patterns, validate assumptions, and communicate findings effectively. A data scientist who masters visualization can bridge the gap between complex data and actionable insights, making data‑driven storytelling a powerful tool for organizations. As data volume and complexity grow, the need for clear, honest, and efficient visualization becomes ever more critical.
डेटा वैज्ञानिक और विश्लेषक अक्सर हज़ारों या लाखों पंक्तियों वाले विशाल डेटासेट के साथ काम करते हैं। तालिकाओं में कच्ची संख्याएँ या केवल सांख्यिकीय सारांश आसानी से रुझानों, पैटर्न, बाहरी बिंदुओं या सहसंबंधों को उजागर नहीं कर पाते। उदाहरण के लिए, 50 शहरों में मासिक बिक्री के आँकड़ों की एक तालिका से यह तुरंत पता लगाना लगभग असंभव है कि कौन से क्षेत्र कम प्रदर्शन कर रहे हैं या समय के साथ बिक्री कैसे बदलती है। मुख्य समस्या है: हम जटिल, बहुआयामी डेटा को एक ऐसे समझने योग्य और कार्रवाई योग्य दृश्य रूप में कैसे बदलें जो एक नज़र में अंतर्दृष्टि प्रकट करे? डेटा विज़ुअलाइज़ेशन ठीक इसी कमी को पूरा करता है।
डेटा विज़ुअलाइज़ेशन : जानकारी और डेटा का ग्राफ़िकल प्रतिनिधित्व। यह डेटा संबंधों, पैटर्न और रुझानों को स्पष्ट और कुशलता से संप्रेषित करने के लिए चार्ट, ग्राफ़, मानचित्र और प्लॉट जैसे दृश्य तत्वों का उपयोग करता है। डेटा साइंस में, यह खोजपूर्ण डेटा विश्लेषण (EDA), मॉडल व्याख्या और हितधारकों को परिणाम संप्रेषित करने के लिए एक महत्वपूर्ण कदम है। यह अमूर्त संख्याओं को दृश्य संदर्भ में बदलता है, अदृश्य को दृश्य बनाता है।
• रेखा चार्ट : पिछले वर्ष में किसी कंपनी के स्टॉक मूल्य का रुझान दिखाता है — ऊपर या नीचे की ढलान तुरंत पहचानी जा सकती है।
• दंड चार्ट : विभिन्न उत्पादों की बिक्री की तुलना; सबसे ऊँचा बार तुरंत सबसे अधिक बिकने वाले उत्पाद की पहचान कराता है।
• बिखराव प्लॉट : विज्ञापन खर्च और राजस्व के बीच संबंध दिखाता है; विकर्ण रेखा पर समूहित बिंदु सहसंबंध का संकेत देते हैं।
• हीटमैप : रंग की तीव्रता के साथ कई चरों का सहसंबंध मैट्रिक्स प्रदर्शित करता है, मजबूत सकारात्मक या नकारात्मक संबंधों को शीघ्रता से उजागर करता है।
कच्चा डेटा → सफ़ाई → अन्वेषण (दृश्य) → मॉडलिंग → व्याख्या (दृश्य) → संचार
| | | |
v v v v
(हिस्टोग्राम, बॉक्सप्लॉट) (बिखराव, हीटमैप) (अवशेष प्लॉट) (डैशबोर्ड, रिपोर्ट)
विज़ुअलाइज़ेशन कोई अलग कदम नहीं है; यह डेटा साइंस पाइपलाइन में सर्वत्र अंतर्निहित है।
डेटा विज़ुअलाइज़ेशन केवल सुंदर चार्ट बनाने के बारे में नहीं है; यह डेटा साइंस कार्यप्रवाह का एक मुख्य घटक है। यह छिपे हुए पैटर्न उजागर करने, धारणाओं को मान्य करने और निष्कर्षों को प्रभावी ढंग से संप्रेषित करने में मदद करता है। एक डेटा वैज्ञानिक जो विज़ुअलाइज़ेशन में निपुण है, जटिल डेटा और कार्रवाई योग्य अंतर्दृष्टि के बीच की खाई को पाट सकता है, डेटा‑संचालित कहानी कहने को संगठनों के लिए एक शक्तिशाली उपकरण बना सकता है। जैसे‑जैसे डेटा की मात्रा और जटिलता बढ़ती है, स्पष्ट, ईमानदार और कुशल विज़ुअलाइज़ेशन की आवश्यकता और भी अधिक महत्वपूर्ण हो जाती है।
Raw numbers stored in lists, arrays, or DataFrames are difficult to interpret directly. Trends, comparisons, and frequency distributions are hidden inside columns of figures. Without visual aids, communicating findings or spotting anomalies becomes slow and error‑prone. The problem is: how to quickly transform numerical data into clear, customizable, and publication‑ready charts that can be saved as image files for reports and sharing. Matplotlib provides a comprehensive toolkit to draw and save essential plots like line plots, bar graphs, and histograms with just a few lines of code.
Line Plot : A chart that displays information as a series of data points connected by straight line segments. Best for showing trends over time or ordered categories.
Bar Graph : A chart that presents categorical data with rectangular bars whose lengths are proportional to the values they represent. Suitable for comparing discrete quantities.
Histogram : A graphical representation of the distribution of numerical data, created by grouping data into bins (intervals) and counting the number of values in each bin.
Saving Plots : Matplotlib’s plt.savefig() function exports the current figure to an image file (PNG, JPG, PDF, SVG, etc.) with control over resolution, size, and background transparency.
Import the library and prepare sample data:
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 10, 50) y = np.sin(x) categories = ['A', 'B', 'C', 'D'] values = [23, 45, 56, 78] data_points = np.random.randn(1000)
Line Plot :
plt.figure(figsize=(6,4))
plt.plot(x, y, color='blue', marker='o', linestyle='-', linewidth=2, markersize=4)
plt.title('Sine Wave Line Plot')
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.grid(True)
plt.savefig('line_plot.png', dpi=150, bbox_inches='tight')
plt.show()
Bar Graph :
plt.figure(figsize=(6,4))
plt.bar(categories, values, color=['red','green','blue','orange'], edgecolor='black')
plt.title('Category Values Bar Graph')
plt.xlabel('Category')
plt.ylabel('Value')
plt.savefig('bar_graph.png', dpi=150, bbox_inches='tight')
plt.show()
Histogram :
plt.figure(figsize=(6,4))
plt.hist(data_points, bins=30, color='purple', edgecolor='white', alpha=0.7)
plt.title('Data Distribution Histogram')
plt.xlabel('Value')
plt.ylabel('Frequency')
plt.savefig('histogram.png', dpi=150, bbox_inches='tight')
plt.show()
plt.barh), stacked bar, grouped bar.plt.hist2d).savefig with high DPI produces crisp graphics for reports and papers.plt.figure without closing can consume memory.plt.subplots() gives explicit control over figure and axes objects.plt.plot uses a state‑machine interface convenient for quick scripts.plt.style.use('ggplot')) and custom rcParams.
Data (list, array, DataFrame)
|
v
+-------------------+
| Create Figure & Axes |
+-------------------+
|
v
+-------------------+
| Call plot type |
| lineplot / bar / hist |
+-------------------+
|
v
+-------------------+
| Customize (title, |
| labels, legend, grid)|
+-------------------+
|
v
+-------------------+
| plt.savefig() | -------> line_plot.png / bar_graph.png / histogram.png
+-------------------+
|
v
plt.show() (optional)
Matplotlib is the foundation of data visualization in Python. Mastering line plots, bar graphs, and histograms equips you to explore trends, compare categories, and understand distributions effectively. The ability to save high‑quality plots with savefig makes it easy to embed visuals in documents, presentations, and dashboards. While it has a learning curve, its power and flexibility make it indispensable for any data‑driven project.
temperature.png.savefig().fig, ax = plt.subplots()) over plt.plot() directly?सूचियों, सरणियों या DataFrame में संग्रहीत कच्ची संख्याओं को सीधे समझना कठिन है। रुझान, तुलना और आवृत्ति वितरण आँकड़ों के स्तंभों के पीछे छिपे रहते हैं। दृश्य सहायता के बिना, निष्कर्षों को संप्रेषित करना या विसंगतियों को पहचानना धीमा और त्रुटिपूर्ण हो जाता है। समस्या है: संख्यात्मक डेटा को शीघ्रता से स्पष्ट, अनुकूलन योग्य और प्रकाशन‑योग्य चार्ट में कैसे बदला जाए जिन्हें रिपोर्ट और साझाकरण के लिए छवि फ़ाइलों के रूप में सहेजा जा सके। Matplotlib केवल कुछ पंक्तियों के कोड के साथ रेखा प्लॉट, दंड ग्राफ और हिस्टोग्राम जैसे आवश्यक प्लॉट बनाने और सहेजने के लिए एक व्यापक टूलकिट प्रदान करता है।
रेखा प्लॉट : एक चार्ट जो जानकारी को सीधी रेखा खंडों से जुड़े डेटा बिंदुओं की एक श्रृंखला के रूप में प्रदर्शित करता है। समय या क्रमित श्रेणियों में रुझान दिखाने के लिए सर्वोत्तम।
दंड ग्राफ : एक चार्ट जो श्रेणीगत डेटा को आयताकार दंडों द्वारा प्रस्तुत करता है, जिनकी लंबाई उनके द्वारा दर्शाए गए मानों के समानुपाती होती है। असतत मात्राओं की तुलना के लिए उपयुक्त।
हिस्टोग्राम : संख्यात्मक डेटा के वितरण का ग्राफिकल निरूपण, डेटा को डिब्बों (अंतराल) में समूहित करके और प्रत्येक डिब्बे में मानों की संख्या गिनकर बनाया जाता है।
प्लॉट सहेजना : Matplotlib का plt.savefig() फंक्शन वर्तमान आकृति को रिज़ॉल्यूशन, आकार और पृष्ठभूमि पारदर्शिता पर नियंत्रण के साथ एक छवि फ़ाइल (PNG, JPG, PDF, SVG आदि) में निर्यात करता है।
लाइब्रेरी आयात करें और नमूना डेटा तैयार करें:
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 10, 50) y = np.sin(x) श्रेणियाँ = ['A', 'B', 'C', 'D'] मान = [23, 45, 56, 78] डेटा_बिंदु = np.random.randn(1000)
रेखा प्लॉट :
plt.figure(figsize=(6,4))
plt.plot(x, y, color='blue', marker='o', linestyle='-', linewidth=2, markersize=4)
plt.title('साइन तरंग रेखा प्लॉट')
plt.xlabel('X अक्ष')
plt.ylabel('Y अक्ष')
plt.grid(True)
plt.savefig('line_plot.png', dpi=150, bbox_inches='tight')
plt.show()
दंड ग्राफ :
plt.figure(figsize=(6,4))
plt.bar(श्रेणियाँ, मान, color=['red','green','blue','orange'], edgecolor='black')
plt.title('श्रेणी मान दंड ग्राफ')
plt.xlabel('श्रेणी')
plt.ylabel('मान')
plt.savefig('bar_graph.png', dpi=150, bbox_inches='tight')
plt.show()
हिस्टोग्राम :
plt.figure(figsize=(6,4))
plt.hist(डेटा_बिंदु, bins=30, color='purple', edgecolor='white', alpha=0.7)
plt.title('डेटा वितरण हिस्टोग्राम')
plt.xlabel('मान')
plt.ylabel('आवृत्ति')
plt.savefig('histogram.png', dpi=150, bbox_inches='tight')
plt.show()
plt.barh), स्टैक्ड दंड, समूहीकृत दंड।plt.hist2d)।savefig रिपोर्ट और पेपर के लिए स्पष्ट ग्राफिक्स उत्पन्न करता है।plt.figure मेमोरी खपत कर सकता है।plt.subplots() आकृति और अक्ष वस्तुओं पर स्पष्ट नियंत्रण देता है।plt.plot एक स्टेट‑मशीन इंटरफ़ेस का उपयोग करता है जो त्वरित स्क्रिप्ट के लिए सुविधाजनक है।plt.style.use('ggplot')) और कस्टम rcParams।
डेटा (सूची, सरणी, DataFrame)
|
v
+-------------------+
| आकृति और अक्ष बनाएँ |
+-------------------+
|
v
+-------------------+
| प्लॉट प्रकार चुनें |
| रेखाचित्र / बार / हिस्ट |
+-------------------+
|
v
+-------------------+
| अनुकूलित करें |
| (शीर्षक, लेबल, लीजेंड)|
+-------------------+
|
v
+-------------------+
| plt.savefig() | -------> line_plot.png / bar_graph.png / histogram.png
+-------------------+
|
v
plt.show() (वैकल्पिक)
Matplotlib, Python में डेटा विज़ुअलाइज़ेशन की नींव है। रेखा प्लॉट, दंड ग्राफ और हिस्टोग्राम में निपुणता आपको रुझानों का पता लगाने, श्रेणियों की तुलना करने और वितरण को प्रभावी ढंग से समझने में सक्षम बनाती है। savefig के साथ उच्च‑गुणवत्ता वाले प्लॉट सहेजने की क्षमता दस्तावेज़ों, प्रस्तुतियों और डैशबोर्ड में दृश्यों को एम्बेड करना आसान बनाती है। हालाँकि इसमें सीखने की अवस्था है, इसकी शक्ति और लचीलापन इसे किसी भी डेटा‑संचालित परियोजना के लिए अनिवार्य बनाते हैं।
temperature.png के रूप में सहेजें।savefig() में प्रयुक्त पैरामीटर दिखाइए।plt.plot() के बजाय ऑब्जेक्ट‑ओरिएंटेड दृष्टिकोण (fig, ax = plt.subplots()) के क्या लाभ हैं?A bare plot without descriptive labels or a title is meaningless to viewers. They cannot know what the axes represent, what the plot is about, or which data series each line or bar corresponds to. Without proper customization, a plot fails to communicate its intended message, leading to confusion and misinterpretation. The core problem is: how to add clear, informative axis labels, a descriptive title, and a legend to a Matplotlib plot so that the visualisation becomes self‑explanatory and ready for presentation or reporting.
Title : A short text displayed at the top of the plot that summarises its content. Added using plt.title() or ax.set_title().
Axis Labels : Text that describes the quantity on the X‑axis and Y‑axis. Added via plt.xlabel() and plt.ylabel() (or ax.set_xlabel(), ax.set_ylabel()).
Legend : A box that explains the mapping between plot elements (lines, bars, markers) and their corresponding data series. Created automatically when a label parameter is given to a plotting function, and then calling plt.legend() (or ax.legend()).
All these functions accept optional parameters for styling: fontsize, color, loc (legend location), etc.
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y1 = [2, 4, 6, 8, 10]
y2 = [1, 3, 5, 7, 9]
plt.figure(figsize=(6,4))
# Plot lines with labels
plt.plot(x, y1, marker='o', label='Series A')
plt.plot(x, y2, marker='s', label='Series B')
# Add title and axis labels
plt.title('Growth of Two Series Over Time', fontsize=14, fontweight='bold')
plt.xlabel('Time (months)', fontsize=12)
plt.ylabel('Value', fontsize=12)
# Add legend
plt.legend(loc='upper left', fontsize=10)
# Show grid (optional)
plt.grid(True, linestyle='--', alpha=0.6)
plt.show()
plt.title('text', fontsize=.., color=.., fontweight=.., loc='center'). The loc parameter can be 'left', 'center', or 'right'.plt.xlabel('text'), plt.ylabel('text') with similar styling arguments. Also labelpad to adjust spacing.plt.legend() with parameters:
loc – 'best', 'upper right', 'lower left', etc. or a (x, y) tuple.ncol – number of columns for legend entries.frameon – True/False to draw a border.title – a title for the legend box.fig, ax = plt.subplots(); then use ax.set_title(), ax.set_xlabel(), ax.legend().plt.title(), plt.xlabel() act on the current figure/axes.ax.set_title() gives explicit control, preferable in complex layouts.r'$\alpha$') and Unicode characters.label attribute, plt.legend() picks it up automatically.plt.tight_layout() prevents clipping of titles and labels when saving.plt.rcParams or style sheets.
Title ("Sales Trend")
┌──────────────────────────────┐
Y label │ * * │ Legend
("Revenue")│ * * Series A │ ┌─Series A
│* * Series B │ └─Series B
└──────────────────────────────┘
X label ("Month")
The title sits at the top, axis labels describe the variables, and the legend explains the symbols.
Adding proper title, axis labels, and a legend transforms a simple chart into an informative visualisation. Matplotlib makes this easy with a few function calls, and the extensive formatting options allow you to match any style guide. Mastering these customizations is essential for effective data communication and is a fundamental skill in data science.
fig, ax = plt.subplots()) to create a bar graph with a title, axis labels, and a custom legend entry (hint: use label in bar and then ax.legend()).plt.rc() or rcParams.plt.tight_layout() and when should you use it?plt.xlabel() and ax.set_xlabel(). Why might you prefer one over the other?बिना वर्णनात्मक लेबल या शीर्षक वाला प्लॉट देखने वालों के लिए अर्थहीन होता है। वे नहीं जान सकते कि अक्ष क्या दर्शाते हैं, प्लॉट किस बारे में है, या कौन सी डेटा श्रृंखला किस रेखा या बार से मेल खाती है। उचित अनुकूलन के बिना, प्लॉट अपना इच्छित संदेश संप्रेषित करने में विफल रहता है, जिससे भ्रम और गलत व्याख्या होती है। मुख्य समस्या है: Matplotlib प्लॉट में स्पष्ट, सूचनात्मक अक्ष लेबल, वर्णनात्मक शीर्षक और एक लीजेंड कैसे जोड़ें ताकि दृश्यीकरण स्वतः व्याख्यात्मक बन जाए और प्रस्तुति या रिपोर्टिंग के लिए तैयार हो।
शीर्षक (Title) : प्लॉट के शीर्ष पर प्रदर्शित एक छोटा पाठ जो इसकी सामग्री का सारांश देता है। plt.title() या ax.set_title() के माध्यम से जोड़ा जाता है।
अक्ष लेबल (Axis Labels) : X‑अक्ष और Y‑अक्ष पर मात्रा का वर्णन करने वाला पाठ। plt.xlabel() और plt.ylabel() (या ax.set_xlabel(), ax.set_ylabel()) से जोड़ें।
लीजेंड (Legend) : एक बॉक्स जो प्लॉट तत्वों (रेखाएँ, बार, मार्कर) और उनकी संबंधित डेटा श्रृंखलाओं के बीच मैपिंग समझाता है। जब किसी प्लॉटिंग फंक्शन में label पैरामीटर दिया जाता है और फिर plt.legend() (या ax.legend()) बुलाया जाता है, तब स्वचालित रूप से बनता है।
ये सभी फंक्शन स्टाइलिंग के लिए वैकल्पिक पैरामीटर स्वीकारते हैं: fontsize, color, loc (लीजेंड का स्थान) आदि।
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y1 = [2, 4, 6, 8, 10]
y2 = [1, 3, 5, 7, 9]
plt.figure(figsize=(6,4))
# लेबल के साथ रेखाएँ प्लॉट करें
plt.plot(x, y1, marker='o', label='श्रृंखला A')
plt.plot(x, y2, marker='s', label='श्रृंखला B')
# शीर्षक और अक्ष लेबल जोड़ें
plt.title('समय के साथ दो श्रृंखलाओं की वृद्धि', fontsize=14, fontweight='bold')
plt.xlabel('समय (महीने)', fontsize=12)
plt.ylabel('मान', fontsize=12)
# लीजेंड जोड़ें
plt.legend(loc='upper left', fontsize=10)
# ग्रिड (वैकल्पिक)
plt.grid(True, linestyle='--', alpha=0.6)
plt.show()
plt.title('text', fontsize=.., color=.., fontweight=.., loc='center')। loc 'left', 'center', या 'right' हो सकता है।plt.xlabel('text'), plt.ylabel('text') समान स्टाइलिंग तर्कों के साथ। अक्ष से दूरी के लिए labelpad भी।plt.legend() निम्न पैरामीटरों के साथ:
loc – 'best', 'upper right', 'lower left', आदि या (x, y) टपल।ncol – लीजेंड प्रविष्टियों के लिए स्तंभों की संख्या।frameon – बॉर्डर खींचने के लिए True/False।title – लीजेंड बॉक्स के लिए शीर्षक।fig, ax = plt.subplots(); फिर ax.set_title(), ax.set_xlabel(), ax.legend()।plt.title(), plt.xlabel() वर्तमान आकृति/अक्ष पर कार्य करते हैं।ax.set_title() स्पष्ट नियंत्रण देता है, जटिल ख़ाकों में पसंदीदा।r'$\alpha$') और यूनिकोड वर्ण समर्थित।label विशेषता है, तो plt.legend() स्वचालित रूप से उसे ले लेता है।plt.tight_layout() सहेजते समय शीर्षक और लेबल को कटने से बचाता है।plt.rcParams या शैली पत्रकों के माध्यम से विश्व स्तर पर सेट किया जा सकता है।
शीर्षक ("बिक्री का रुझान")
┌──────────────────────────────┐
Y लेबल │ * * │ लीजेंड
("राजस्व")│ * * श्रृंखला A │ ┌─श्रृंखला A
│* * श्रृंखला B │ └─श्रृंखला B
└──────────────────────────────┘
X लेबल ("महीना")
शीर्षक शीर्ष पर, अक्ष लेबल चरों का वर्णन करते हैं, और लीजेंड प्रतीकों की व्याख्या करता है।
उचित शीर्षक, अक्ष लेबल और लीजेंड जोड़ना एक साधारण चार्ट को जानकारीपूर्ण दृश्यीकरण में बदल देता है। Matplotlib इसे कुछ फंक्शन कॉल के साथ सरल बनाता है, और व्यापक स्वरूपण विकल्प आपको किसी भी शैली गाइड से मिलान करने देते हैं। इन अनुकूलनों में निपुणता प्रभावी डेटा संचार के लिए आवश्यक है और डेटा साइंस में एक मूलभूत कौशल है।
fig, ax = plt.subplots()) का उपयोग करके एक बार ग्राफ बनाएँ जिसमें शीर्षक, अक्ष लेबल और कस्टम लीजेंड प्रविष्टि हो (संकेत: bar में label दें और फिर ax.legend() करें)।plt.rc() या rcParams का उपयोग करके उदाहरण दिखाएँ।plt.tight_layout() का उद्देश्य क्या है और इसका उपयोग कब करना चाहिए?plt.xlabel() और ax.set_xlabel() के बीच अंतर समझाइए। एक को दूसरे पर क्यों प्राथमिकता देंगे?Before networks, computers worked in isolation. Transferring a file from one computer to another required copying it onto a floppy disk or CD and physically carrying it to the other machine. Sharing a printer meant unplugging it from one computer and reconnecting it to another. Accessing information stored on a different system was impossible without direct physical access. The core problem was: how to enable multiple computers to communicate, share resources (files, printers, internet access), and exchange data efficiently without physical movement of media. Computer networks solve exactly this by connecting computers together.
Computer Network : A collection of interconnected autonomous computers and devices that can communicate with each other and share resources (hardware, software, data). The connection can be through cables (wired) or wireless signals. Networks use standard protocols (rules) to ensure reliable communication. The internet itself is the largest example of a network of networks.
• Home Wi‑Fi : A laptop, smartphone, and printer connected to the same Wi‑Fi router form a small network. The printer can be used wirelessly from any device, and all can access the internet through the same connection.
• School Lab : Multiple computers connected by Ethernet cables to a switch can share a central printer and access files stored on a server.
• Internet : Millions of computers worldwide connected together, allowing services like the World Wide Web, email, video streaming, and social media.
Computer networks are categorized by their geographic span:
[Laptop] [Smartphone]
\ /
\ /
+-----------------+
| Router/Wi-Fi |
+--------+--------+
|
+---------+---------+
| |
[Printer] [Internet Cloud]
|
(Shared resource)
A simple home network showing devices connected to a router, sharing internet and a printer.
Computer networks have become the backbone of modern communication and business. They allow us to share resources, access information globally, and collaborate in real‑time. Understanding the basic types, benefits, and limitations of networks is essential for anyone entering the field of computer science or IT. As technology evolves, networks continue to become faster, more secure, and more integral to daily life.
नेटवर्क से पहले, कंप्यूटर अलग‑थलग काम करते थे। एक कंप्यूटर से दूसरे में फ़ाइल भेजने के लिए फ़्लॉपी डिस्क या CD में कॉपी करके उसे भौतिक रूप से ले जाना पड़ता था। प्रिंटर साझा करने का मतलब था उसे एक कंप्यूटर से निकालकर दूसरे में लगाना। दूसरे सिस्टम पर रखी जानकारी तक पहुँच असंभव थी। मुख्य समस्या थी: कई कंप्यूटरों को बिना मीडिया के भौतिक आवागमन के, संसाधन (फ़ाइलें, प्रिंटर, इंटरनेट) साझा करने और डेटा का कुशल आदान‑प्रदान करने के योग्य कैसे बनाया जाए। कंप्यूटर नेटवर्क इसी समस्या का समाधान करते हैं।
कंप्यूटर नेटवर्क : आपस में जुड़े स्वायत्त कंप्यूटरों और उपकरणों का एक समूह जो एक‑दूसरे से संवाद कर सकते हैं और संसाधन (हार्डवेयर, सॉफ़्टवेयर, डेटा) साझा कर सकते हैं। कनेक्शन केबल (वायर्ड) या वायरलेस सिग्नल के माध्यम से हो सकता है। नेटवर्क विश्वसनीय संचार के लिए मानक प्रोटोकॉल (नियम) का उपयोग करते हैं। इंटरनेट स्वयं नेटवर्कों का सबसे बड़ा नेटवर्क है।
• होम वाई‑फ़ाई : एक ही वाई‑फ़ाई राउटर से जुड़े लैपटॉप, स्मार्टफ़ोन और प्रिंटर एक छोटा नेटवर्क बनाते हैं। प्रिंटर का उपयोग किसी भी उपकरण से वायरलेस रूप से किया जा सकता है और सभी एक ही कनेक्शन से इंटरनेट का उपयोग कर सकते हैं।
• स्कूल लैब : ईथरनेट केबल से स्विच से जुड़े कई कंप्यूटर एक केंद्रीय प्रिंटर साझा कर सकते हैं और सर्वर पर फ़ाइलें एक्सेस कर सकते हैं।
• इंटरनेट : दुनिया भर में जुड़े लाखों कंप्यूटर, वर्ल्ड वाइड वेब, ईमेल, वीडियो स्ट्रीमिंग और सोशल मीडिया जैसी सेवाएँ संभव बनाते हैं।
कंप्यूटर नेटवर्क को भौगोलिक विस्तार के आधार पर वर्गीकृत किया जाता है:
[लैपटॉप] [स्मार्टफ़ोन]
\ /
\ /
+-----------------+
| राउटर/वाई-फ़ाई |
+--------+--------+
|
+---------+---------+
| |
[प्रिंटर] [इंटरनेट क्लाउड]
|
(साझा संसाधन)
एक साधारण होम नेटवर्क जिसमें उपकरण राउटर से जुड़े हैं और इंटरनेट व प्रिंटर साझा कर रहे हैं।
कंप्यूटर नेटवर्क आधुनिक संचार और व्यवसाय की रीढ़ बन गए हैं। ये हमें संसाधन साझा करने, वैश्विक जानकारी तक पहुँचने और वास्तविक समय में सहयोग करने की अनुमति देते हैं। नेटवर्क के बुनियादी प्रकार, लाभ और सीमाओं को समझना कंप्यूटर विज्ञान या आईटी के क्षेत्र में प्रवेश करने वाले किसी भी व्यक्ति के लिए आवश्यक है। जैसे‑जैसे प्रौद्योगिकी विकसित होती है, नेटवर्क तेज़, अधिक सुरक्षित और दैनिक जीवन के लिए और अधिक अभिन्न बनते जा रहे हैं।
In early computing, each computer was an isolated island. To move a file, one had to copy it onto a floppy disk or tape and physically carry it to another machine. Sharing a printer or an internet connection was impossible without physically reconnecting cables. As organisations grew, the need arose to connect computers that were in the same room, the same building, the same city, or even across continents. A single solution could not fit all these scenarios because distance directly affects speed, cost, and technology. The core problem was: how to classify networks based on the geographical area they cover so that we can choose the right technology for the right scale. This led to the standard types: PAN, LAN, MAN, and WAN.
Computer networks are categorised by their physical span and the technology used to connect devices. The four primary types are:
• PAN : A Bluetooth connection between a smartphone and wireless earphones, or a laptop syncing with a smartwatch.
• LAN : All computers in a school computer lab connected by Ethernet cables to a switch, sharing a printer and a file server.
• MAN : A city‑wide Wi‑Fi network provided by a municipal corporation, or a cable television network in a city.
• WAN : The Internet itself – connecting billions of devices worldwide. A corporate VPN connecting branch offices across different countries is also a WAN.
The types themselves are the focus; here is a comparative description:
+--------------------------------------------------+ | WAN (Internet) | | +-----------------------+ +------------------+ | | | MAN (City) | | MAN (City 2) | | | | +--------+ +------+ | +------------------+ | | | |LAN(Off)| |LAN(Uni)| | | | +--+--------+-+------+--+ | | | PAN | | PAN | | | |(Bluetooth) (Bluetooth)| | +--------------------------------------------------+
The hierarchy shows how smaller networks are nested within larger ones; PAN inside LAN, LAN inside MAN, MAN inside WAN.
Classifying networks into PAN, LAN, MAN, and WAN helps engineers and organisations select the right technology, design appropriate infrastructure, and estimate costs. PAN solves personal device connectivity; LAN is the backbone of any office; MAN bridges the gap between local and wide area; and WAN makes the world a global village. A sound understanding of these types is fundamental to networking and IT infrastructure planning.
प्रारंभिक कंप्यूटिंग में हर कंप्यूटर एक अलग द्वीप था। फ़ाइल स्थानांतरित करने के लिए उसे फ़्लॉपी या टेप पर कॉपी करके दूसरी मशीन तक भौतिक रूप से ले जाना पड़ता था। प्रिंटर या इंटरनेट कनेक्शन साझा करना असंभव था। जैसे‑जैसे संगठन बढ़े, एक ही कमरे, एक ही इमारत, एक ही शहर या महाद्वीपों में फैले कंप्यूटरों को जोड़ने की ज़रूरत पैदा हुई। एक ही समाधान सभी परिदृश्यों में फिट नहीं बैठता था क्योंकि दूरी सीधे गति, लागत और प्रौद्योगिकी को प्रभावित करती है। मुख्य समस्या थी: नेटवर्कों को उनके भौगोलिक क्षेत्र के आधार पर कैसे वर्गीकृत किया जाए ताकि सही पैमाने के लिए सही तकनीक चुनी जा सके। इसी ने मानक प्रकारों को जन्म दिया: PAN, LAN, MAN, और WAN।
कंप्यूटर नेटवर्कों को उनके भौतिक विस्तार और उपयोग की गई तकनीक के आधार पर वर्गीकृत किया जाता है। चार मुख्य प्रकार हैं:
• PAN : स्मार्टफ़ोन और वायरलेस इयरफ़ोन के बीच ब्लूटूथ कनेक्शन, या लैपटॉप का स्मार्टवॉच से सिंक होना।
• LAN : स्कूल की कंप्यूटर लैब में सभी कंप्यूटरों का ईथरनेट केबल से स्विच से जुड़ना और एक प्रिंटर तथा फ़ाइल सर्वर साझा करना।
• MAN : नगर निगम द्वारा प्रदान किया गया शहर‑व्यापी वाई‑फ़ाई नेटवर्क, या किसी शहर का केबल टीवी नेटवर्क।
• WAN : स्वयं इंटरनेट – दुनिया भर के अरबों उपकरणों को जोड़ता है। किसी कंपनी का VPN जो विभिन्न देशों के शाखा कार्यालयों को जोड़ता है, वह भी WAN है।
ये प्रकार ही मुख्य विषय हैं; यहाँ तुलनात्मक विवरण है:
+--------------------------------------------------+ | WAN (इंटरनेट) | | +-----------------------+ +------------------+ | | | MAN (शहर) | | MAN (शहर 2) | | | | +--------+ +------+ | +------------------+ | | | |LAN(कार्यालय)|LAN(यूनिवर्सिटी)| | | | +--+--------+-+------+--+ | | | PAN | | PAN | | | |(ब्लूटूथ) (ब्लूटूथ)| | +--------------------------------------------------+
यह पदानुक्रम दिखाता है कि छोटे नेटवर्क बड़ों के अंदर कैसे स्थित हैं; PAN, LAN के अंदर; LAN, MAN के अंदर; MAN, WAN के अंदर।
नेटवर्कों को PAN, LAN, MAN और WAN में वर्गीकृत करना इंजीनियरों और संगठनों को सही तकनीक चुनने, उपयुक्त बुनियादी ढाँचा डिज़ाइन करने और लागत का अनुमान लगाने में मदद करता है। PAN व्यक्तिगत उपकरण कनेक्टिविटी का समाधान करता है; LAN किसी भी कार्यालय की रीढ़ है; MAN स्थानीय और विस्तृत क्षेत्र के बीच की खाई को पाटता है; और WAN दुनिया को एक वैश्विक गाँव बनाता है। इन प्रकारों की ठोस समझ नेटवर्किंग और IT अवसंरचना योजना के लिए मौलिक है।
When computers are connected in a network, they need special hardware to send and receive data correctly. Without the right devices, signals weaken over distance, data collides, and different types of networks cannot communicate. For example, connecting a home network to the internet requires converting digital signals to analog for the telephone line. Sharing data among many computers inside an office without chaos demands intelligent forwarding. The problem is: how to use specialized network devices to enable smooth, efficient, and secure communication between computers, extend network reach, and interconnect different network technologies. Each device — modem, hub, switch, repeater, router, and gateway — solves a specific piece of this problem.
Modem (Modulator‑Demodulator): Converts digital signals from a computer into analog signals for transmission over telephone lines (modulation) and vice versa (demodulation).
Hub: A simple networking device that connects multiple computers in a LAN. It broadcasts incoming data packets to all connected devices regardless of the intended recipient.
Switch: An intelligent device that connects devices in a LAN and forwards data frames only to the specific port where the destination device is connected, using MAC addresses.
Repeater: A device that regenerates and amplifies weakened signals to extend the physical range of a network.
Router: Connects different networks (e.g., a home LAN to the internet). It forwards data packets based on IP addresses, choosing the best path using routing tables.
Gateway: A network point that acts as an entrance to another network. It can translate between different communication protocols, architectures, or data formats.
• Modem: The device provided by your internet service provider (ISP) that connects your home router to the telephone line or fibre optic cable.
• Hub: (Older networks) A small box with many Ethernet ports; plugging in four computers results in every packet being sent to all four.
• Switch: In a modern office, a 24‑port switch connects all desktops. When computer A sends data to computer B, the switch sends it only to port B.
• Repeater: A Wi‑Fi range extender that picks up a weak wireless signal and retransmits it to cover a dead zone.
• Router: The home Wi‑Fi router connects your local devices (laptop, phone) to the internet and assigns local IP addresses (DHCP).
• Gateway: An IoT gateway that collects data from Zigbee sensors and forwards it to a cloud server using TCP/IP, translating protocols.
Internet
|
Modem
|
Router (with firewall)
|
Switch
/ | \
/ | \
PC1 PC2 Printer
Repeater can be placed between Router and Switch if distance is long.
A Gateway sits between networks of different protocols (e.g., an IoT Gateway connecting Zigbee sensors to the IP network).
Each network device plays a specific, essential role in building and maintaining a functional network. From signal conversion (Modem) and signal boosting (Repeater) to efficient internal communication (Switch) and inter‑network routing (Router, Gateway), they form a layered ecosystem. Understanding their functions, advantages, and limitations is critical for designing, troubleshooting, and securing any computer network.
जब कंप्यूटर नेटवर्क में जुड़े होते हैं, तो उन्हें डेटा सही तरीके से भेजने और प्राप्त करने के लिए विशेष हार्डवेयर की आवश्यकता होती है। सही उपकरणों के बिना, दूरी के साथ सिग्नल कमज़ोर पड़ जाता है, डेटा टकराता है और भिन्न प्रकार के नेटवर्क संवाद नहीं कर पाते। उदाहरण के लिए, घर के नेटवर्क को इंटरनेट से जोड़ने के लिए डिजिटल सिग्नलों को टेलीफ़ोन लाइन के एनालॉग सिग्नलों में बदलना पड़ता है। किसी कार्यालय में अनेक कंप्यूटरों के बीच अराजकता के बिना डेटा साझा करने के लिए समझदारी से अग्रेषण की आवश्यकता होती है। समस्या है: विशेष नेटवर्क उपकरणों का उपयोग करके कंप्यूटरों के बीच सुचारू, कुशल और सुरक्षित संचार कैसे सुनिश्चित किया जाए, नेटवर्क की पहुँच बढ़ाई जाए और विभिन्न नेटवर्क प्रौद्योगिकियों को आपस में जोड़ा जाए। Modem, Hub, Switch, Repeater, Router, और Gateway — प्रत्येक इस समस्या का एक विशेष भाग हल करता है।
Modem (मॉडम): कंप्यूटर के डिजिटल सिग्नलों को टेलीफोन लाइनों पर भेजने के लिए एनालॉग सिग्नलों में बदलता है (मॉड्यूलेशन) और वापस डिजिटल में बदलता है (डीमॉड्यूलेशन)।
Hub (हब): एक साधारण उपकरण जो LAN में कई कंप्यूटरों को जोड़ता है। यह आने वाले डेटा पैकेट को सभी जुड़े उपकरणों पर प्रसारित कर देता है, चाहे प्राप्तकर्ता कोई भी हो।
Switch (स्विच): एक बुद्धिमान उपकरण जो LAN में उपकरणों को जोड़ता है और MAC पतों के आधार पर डेटा फ्रेम केवल उसी पोर्ट पर भेजता है जहाँ गंतव्य उपकरण जुड़ा है।
Repeater (रिपीटर): कमज़ोर पड़ चुके सिग्नलों को पुनर्जीवित और प्रवर्धित करके नेटवर्क की भौतिक सीमा बढ़ाने वाला उपकरण।
Router (राउटर): विभिन्न नेटवर्कों (जैसे, होम LAN को इंटरनेट) को जोड़ता है। यह IP पतों के आधार पर डेटा पैकेट अग्रेषित करता है और रूटिंग तालिकाओं का उपयोग करके सर्वोत्तम मार्ग चुनता है।
Gateway (गेटवे): एक ऐसा नेटवर्क बिंदु जो दूसरे नेटवर्क में प्रवेश द्वार का काम करता है। यह विभिन्न संचार प्रोटोकॉल, आर्किटेक्चर या डेटा प्रारूपों के बीच अनुवाद कर सकता है।
• Modem: आपके इंटरनेट सेवा प्रदाता (ISP) द्वारा दिया गया उपकरण जो आपके घर के राउटर को टेलीफ़ोन लाइन या फ़ाइबर ऑप्टिक केबल से जोड़ता है।
• Hub: (पुराने नेटवर्क) ईथरनेट पोर्ट वाला एक छोटा बक्सा; चार कंप्यूटर लगाने पर हर पैकेट सभी चारों को भेजा जाता है।
• Switch: आधुनिक कार्यालय में, 24‑पोर्ट स्विच सभी डेस्कटॉप जोड़ता है। जब कंप्यूटर A, कंप्यूटर B को डेटा भेजता है, तो स्विच केवल पोर्ट B पर भेजता है।
• Repeater: वाई‑फ़ाई रेंज एक्सटेंडर जो कमज़ोर वायरलेस सिग्नल पकड़कर उसे पुनः प्रेषित कर डेड ज़ोन को कवर करता है।
• Router: घर का वाई‑फ़ाई राउटर आपके स्थानीय उपकरणों (लैपटॉप, फ़ोन) को इंटरनेट से जोड़ता है और स्थानीय IP पते (DHCP) देता है।
• Gateway: एक IoT गेटवे जो Zigbee सेंसरों से डेटा एकत्रित कर TCP/IP के माध्यम से क्लाउड सर्वर को भेजता है, प्रोटोकॉल का अनुवाद करते हुए।
इंटरनेट
|
Modem
|
Router (फ़ायरवॉल के साथ)
|
Switch
/ | \
/ | \
PC1 PC2 Printer
Repeater को Router और Switch के बीच लगाया जा सकता है यदि दूरी अधिक हो।
Gateway, भिन्न प्रोटोकॉल वाले नेटवर्कों (जैसे Zigbee सेंसरों को IP नेटवर्क से जोड़ने वाला IoT Gateway) के बीच बैठता है।
प्रत्येक नेटवर्क डिवाइस एक क्रियाशील नेटवर्क बनाने और बनाए रखने में एक विशिष्ट, आवश्यक भूमिका निभाता है। सिग्नल रूपांतरण (Modem) और सिग्नल प्रवर्धन (Repeater) से लेकर कुशल आंतरिक संचार (Switch) और अंतर‑नेटवर्क रूटिंग (Router, Gateway) तक, ये एक स्तरित पारिस्थितिकी तंत्र बनाते हैं। इनके कार्यों, लाभों और सीमाओं को समझना किसी भी कंप्यूटर नेटवर्क के डिज़ाइन, समस्या निवारण और सुरक्षा के लिए महत्वपूर्ण है।
When multiple computers and devices need to be connected in a network, simply joining them with random cables leads to chaos — cable clutter, data collisions, difficult troubleshooting, and poor scalability. A proper physical or logical arrangement is required so that every device can communicate efficiently, expansion is easy, and faults are quickly detected. The core problem is: how to arrange the connections between network nodes in a systematic way that optimises cost, performance, reliability, and ease of maintenance. Network topology provides the blueprint for this arrangement.
Network Topology : The geometric arrangement of computers and devices in a network — how they are connected to each other, both physically (cable layout) and logically (data flow paths). A well‑chosen topology determines how data travels, how faults are isolated, and how easily the network can grow. Common topologies include Star, Bus, Tree, and Mesh.
• Star: All computers in an office connect to a central switch via individual cables. If one cable fails, only that computer is affected; others keep working.
• Bus: A single backbone cable (like an old coaxial Ethernet) runs along a corridor, and each computer taps into it. If the backbone breaks, the whole network goes down.
• Tree: A university network: the main switch in the server room connects to floor switches, which in turn connect to lab computers — a hierarchical structure.
• Mesh: In a military communication system, every radio node is connected to several others, so even if a few links are destroyed, connectivity remains.
Star Topology Bus Topology
N N N N
\ \ / \ /
\ \ / \ /
Hub ---- N ====================
/ (single cable)
/ T T
N (terminator) (terminator)
Tree Topology (hierarchical)
Root
/ \
Hub1 Hub2
/ \ / \
N N N N
Mesh Topology (fully connected)
N--------N
| \ / |
| \ / |
| \/ |
| /\ |
| / \ |
N--------N
(every node connected to every other)
Choosing the right network topology is crucial for balancing cost, performance, and reliability. Star topology dominates modern LANs because of its simplicity and fault isolation. Bus, though largely obsolete, is historically significant. Tree topology is ideal for large, scalable organisations, while Mesh is reserved for mission‑critical systems where downtime is unacceptable. Understanding these topologies helps network designers build efficient, resilient networks.
जब कई कंप्यूटर और उपकरण नेटवर्क में जोड़े जाने हों, तो बिना सोचे‑समझे तार जोड़ने से अव्यवस्था फैलती है — केबलों का जाल, डेटा टकराव, समस्या पहचानने में कठिनाई और ख़राब विस्तारणीयता। एक उचित भौतिक या तार्किक व्यवस्था आवश्यक है ताकि प्रत्येक उपकरण कुशलता से संवाद कर सके, विस्तार आसान हो और गड़बड़ी तुरंत पकड़ी जाए। मुख्य समस्या है: नेटवर्क नोड्स के बीच कनेक्शनों को इस प्रकार व्यवस्थित कैसे किया जाए कि लागत, प्रदर्शन, विश्वसनीयता और रखरखाव में संतुलन बना रहे। नेटवर्क टोपोलॉजी इसी व्यवस्था का खाका प्रदान करती है।
नेटवर्क टोपोलॉजी : नेटवर्क में कंप्यूटरों और उपकरणों की ज्यामितीय व्यवस्था — वे आपस में कैसे जुड़े हैं, भौतिक रूप से (केबल लेआउट) और तार्किक रूप से (डेटा प्रवाह पथ)। एक अच्छी तरह से चुनी गई टोपोलॉजी यह तय करती है कि डेटा कैसे यात्रा करता है, खराबी कैसे अलग की जाती है और नेटवर्क कितनी आसानी से बढ़ सकता है। प्रमुख टोपोलॉजी में स्टार, बस, ट्री और मेश शामिल हैं।
• स्टार: किसी कार्यालय के सभी कंप्यूटर अलग‑अलग केबल से एक केंद्रीय स्विच से जुड़ते हैं। यदि एक केबल खराब हो जाए, तो केवल वह कंप्यूटर प्रभावित होता है; बाकी चलते रहते हैं।
• बस: एक मुख्य बैकबोन केबल (जैसे पुरानी कोएक्सियल ईथरनेट) गलियारे में बिछाई जाती है और हर कंप्यूटर उसमें टैप करता है। यदि बैकबोन टूट जाए, तो पूरा नेटवर्क ठप।
• ट्री: एक विश्वविद्यालय का नेटवर्क: सर्वर रूम का मुख्य स्विच मंज़िल के स्विचों से जुड़ता है, जो आगे प्रयोगशाला के कंप्यूटरों से जुड़ते हैं — एक पदानुक्रमित संरचना।
• मेश: सैन्य संचार प्रणाली में, हर रेडियो नोड कई अन्य से जुड़ा होता है, जिससे कुछ लिंक नष्ट होने पर भी संपर्क बना रहता है।
स्टार टोपोलॉजी बस टोपोलॉजी
N N N N
\ \ / \ /
\ \ / \ /
Hub ---- N ====================
/ (एकल केबल)
/ T T
N (टर्मिनेटर) (टर्मिनेटर)
ट्री टोपोलॉजी (पदानुक्रमित)
रूट
/ \
हब1 हब2
/ \ / \
N N N N
मेश टोपोलॉजी (पूर्णतः जुड़ी)
N--------N
| \ / |
| \ / |
| \/ |
| /\ |
| / \ |
N--------N
(हर नोड हर दूसरे से जुड़ा है)
सही नेटवर्क टोपोलॉजी चुनना लागत, प्रदर्शन और विश्वसनीयता के बीच संतुलन बनाने के लिए महत्वपूर्ण है। आधुनिक LAN में स्टार टोपोलॉजी अपनी सरलता और खराबी अलग करने की क्षमता के कारण हावी है। बस, हालाँकि अब अप्रचलित है, ऐतिहासिक रूप से महत्वपूर्ण है। ट्री बड़े, मापनीय संगठनों के लिए आदर्श है, जबकि मेश उन अति‑महत्वपूर्ण प्रणालियों के लिए आरक्षित है जहाँ डाउनटाइम अस्वीकार्य है। इन टोपोलॉजियों को समझना नेटवर्क डिज़ाइनरों को कुशल, लचीले नेटवर्क बनाने में मदद करता है।
Before the internet, information was isolated in separate computers or local networks. Sharing a document meant physically copying it onto a disk and delivering it. Finding the latest news, sending instant messages to a friend in another country, or talking face‑to‑face over a video call was either impossible or extremely expensive. There was no unified way to access files stored on different types of machines across the globe. The core problem was: how to interconnect millions of computers worldwide so that they can seamlessly exchange information, locate resources using a simple addressing scheme, and support diverse communication services like web browsing, email, chat, and voice calls. The internet, the World Wide Web (WWW), and the URL system together solved this.
Internet: A global network of billions of computers and other electronic devices. It uses the TCP/IP protocol suite to link devices together, allowing them to communicate irrespective of their hardware or software.
URL (Uniform Resource Locator): The address of a specific webpage or file on the internet (e.g., https://www.example.com/index.html). A URL consists of a protocol (https), a domain name (www.example.com), and an optional path to a resource.
WWW (World Wide Web): A system of interlinked hypertext documents and other resources accessed via the internet. It is the most popular service running on the internet, where webpages are connected through hyperlinks and viewed using web browsers.
Applications of Internet:
• Web: Browsing and retrieving information from websites (static or dynamic) using HTTP/HTTPS.
• Email: Exchanging digital messages using protocols like SMTP, POP3, IMAP. Examples: Gmail, Outlook.
• Chat: Real‑time text communication over the internet. Examples: WhatsApp, Telegram, Facebook Messenger.
• VoIP (Voice over Internet Protocol): Making voice and video calls over the internet instead of traditional telephone lines. Examples: Skype, Zoom, Google Meet.
• Web Browsing: A student types https://www.wikipedia.org in a browser. The URL tells the browser exactly where to fetch the page; the WWW displays the article with hyperlinks to other topics.
• Email: A teacher sends a homework assignment to 30 students at once using a mailing list. The email travels across the internet and arrives in inboxes within seconds.
• Chat: Two friends use WhatsApp to share photos and short messages in real time, even though one is in India and the other in Canada.
• VoIP: A doctor conducts a video consultation with a patient using Zoom, saving travel time and allowing immediate visual diagnosis.
Internet applications can be categorised by the type of communication they support:
[User] —— (browser) —— https://www.example.com —— [Web Server]
|
|—— (email client) —— SMTP/POP3 —— [Mail Server]
|
|—— (chat app) —— XMPP/ proprietary —— [Chat Server]
|
|—— (VoIP phone) —— SIP/RTP —— [VoIP Server]
all traversing the
+------------+
| INTERNET |
+------------+
The internet carries data for all services; URLs locate web resources; WWW is the collection of webpages accessed via browsers.
The internet has transformed how we live, work, and communicate. Understanding its core components—URL, WWW, and the various applications like web, email, chat, and VoIP—is essential for any student of computer science. It not only provides the foundation for today’s digital world but also opens doors to building future technologies. As the internet continues to evolve, staying informed about its benefits and challenges remains critical.
इंटरनेट से पहले, जानकारी अलग‑अलग कंप्यूटरों या स्थानीय नेटवर्कों में बंद थी। कोई दस्तावेज़ साझा करने के लिए उसे डिस्क पर कॉपी करके भौतिक रूप से ले जाना पड़ता था। नवीनतम समाचार ढूँढना, दूसरे देश में बैठे मित्र को तुरंत संदेश भेजना या वीडियो कॉल पर आमने‑सामने बात करना या तो असंभव था या बहुत महँगा। दुनिया भर के विभिन्न प्रकार के कंप्यूटरों पर रखी फ़ाइलों तक पहुँच का कोई एकीकृत तरीका नहीं था। मुख्य समस्या थी: दुनिया भर के लाखों कंप्यूटरों को इस तरह कैसे जोड़ा जाए कि वे बिना किसी बाधा के सूचना का आदान‑प्रदान कर सकें, एक सरल पता प्रणाली (URL) से संसाधन ढूँढ सकें, और वेब ब्राउज़िंग, ईमेल, चैट और वॉइस कॉल जैसी विविध सेवाएँ प्रदान कर सकें। इंटरनेट, वर्ल्ड वाइड वेब (WWW) और URL प्रणाली ने मिलकर यह समस्या हल की।
इंटरनेट: अरबों कंप्यूटरों और अन्य इलेक्ट्रॉनिक उपकरणों का एक वैश्विक नेटवर्क। यह TCP/IP प्रोटोकॉल सूट का उपयोग करके उपकरणों को जोड़ता है, जिससे वे अपने हार्डवेयर या सॉफ़्टवेयर की परवाह किए बिना संवाद कर सकते हैं।
URL (यूनिफ़ॉर्म रिसोर्स लोकेटर): इंटरनेट पर किसी विशिष्ट वेबपेज या फ़ाइल का पता (जैसे, https://www.example.com/index.html)। एक URL में प्रोटोकॉल (https), डोमेन नाम (www.example.com) और संसाधन का पथ शामिल होता है।
WWW (वर्ल्ड वाइड वेब): इंटरनेट के माध्यम से सुलभ आपस में जुड़े हाइपरटेक्स्ट दस्तावेज़ों और अन्य संसाधनों की एक प्रणाली। यह इंटरनेट पर चलने वाली सबसे लोकप्रिय सेवा है, जहाँ वेबपेज हाइपरलिंक द्वारा जुड़े होते हैं और वेब ब्राउज़र से देखे जाते हैं।
इंटरनेट के अनुप्रयोग:
• वेब: वेबसाइटों से HTTP/HTTPS के माध्यम से जानकारी प्राप्त करना।
• ईमेल: SMTP, POP3, IMAP प्रोटोकॉलों का उपयोग करके डिजिटल संदेशों का आदान‑प्रदान। उदाहरण: Gmail, Outlook।
• चैट: इंटरनेट पर वास्तविक समय में पाठ संचार। उदाहरण: WhatsApp, Telegram, Facebook Messenger।
• VoIP (वॉइस ओवर इंटरनेट प्रोटोकॉल): पारंपरिक टेलीफ़ोन लाइनों के बजाय इंटरनेट पर आवाज़ और वीडियो कॉल करना। उदाहरण: Skype, Zoom, Google Meet।
• वेब ब्राउज़िंग: एक छात्र ब्राउज़र में https://www.wikipedia.org टाइप करता है। URL ब्राउज़र को बताता है कि पेज कहाँ से लाना है; WWW उस लेख को हाइपरलिंक के साथ दिखाता है।
• ईमेल: एक शिक्षक 30 छात्रों को एक साथ होमवर्क भेजता है। ईमेल इंटरनेट के ज़रिए कुछ ही सेकंड में इनबॉक्स में पहुँच जाता है।
• चैट: दो दोस्त WhatsApp पर तस्वीरें और संदेश साझा करते हैं, भले ही एक भारत में हो और दूसरा कनाडा में।
• VoIP: एक डॉक्टर Zoom का उपयोग करके मरीज़ से वीडियो परामर्श करता है, जिससे यात्रा समय बचता है और तुरंत दृश्य निदान संभव होता है।
इंटरनेट अनुप्रयोगों को संचार के प्रकार के आधार पर वर्गीकृत किया जा सकता है:
[उपयोगकर्ता] —— (ब्राउज़र) —— https://www.example.com —— [वेब सर्वर]
|
|—— (ईमेल क्लाइंट) —— SMTP/POP3 —— [मेल सर्वर]
|
|—— (चैट ऐप) —— XMPP/मालिकाना —— [चैट सर्वर]
|
|—— (VoIP फ़ोन) —— SIP/RTP —— [VoIP सर्वर]
सभी इसके माध्यम से गुज़रते हैं
+------------+
| इंटरनेट |
+------------+
इंटरनेट सभी सेवाओं के लिए डेटा ले जाता है; URL वेब संसाधनों का पता बताता है; WWW ब्राउज़र द्वारा एक्सेस किए जाने वाले वेबपेजों का संग्रह है।
इंटरनेट ने हमारे जीने, काम करने और संवाद करने के तरीके को बदल दिया है। इसके मुख्य घटकों — URL, WWW और वेब, ईमेल, चैट, VoIP जैसे विभिन्न अनुप्रयोगों — को समझना कंप्यूटर विज्ञान के किसी भी छात्र के लिए आवश्यक है। यह न केवल आज की डिजिटल दुनिया की नींव प्रदान करता है बल्कि भविष्य की प्रौद्योगिकियों के निर्माण के द्वार भी खोलता है। जैसे‑जैसे इंटरनेट विकसित होता जा रहा है, इसके लाभों और चुनौतियों के बारे में जागरूक रहना महत्वपूर्ण बना हुआ है।
When you open a browser and type an address like www.school.edu, you see a collection of pages with text, images, and links. Yet, people often confuse the terms "webpage" and "website". For example, they might say "I created a webpage" when they actually built a whole site with many pages, or think a single document like a PDF is a website. This confusion leads to misunderstandings in web development, communication with clients, and even in exam answers. The problem is: how to clearly define what a website is and distinguish it from a single webpage, so that we can talk about the web accurately and understand how they are related.
Webpage : A single document on the World Wide Web that can be displayed in a web browser. It is written in HTML and may contain text, images, videos, hyperlinks, and other elements. A webpage is identified by a unique URL (e.g., https://www.example.com/contact.html).
Website : A collection of related webpages grouped under a single domain name. A website typically has a homepage that links to other pages, and all pages share a common theme, navigation, and design. For example, www.school.edu is a website that contains pages like /admissions.html, /gallery.html, /contact.html.
• Webpage: The "About Us" page of a company (www.company.com/about) is a single webpage. It contains the company's history, mission, and team photos.
• Website: The entire www.company.com domain with its Home, About, Products, Contact pages is the website.
• Think of a book: a webpage is like a single page in the book, while the website is the entire book with its cover, table of contents, and all chapters.
Websites can be classified based on content, functionality, and technology:
example.com); a webpage has a specific URL path under that domain.Website: www.school.edu +----------------------------------------------+ | Homepage (index.html) | | | | | +----> About Us (about.html) | | +----> Gallery (gallery.html) | | +----> Contact (contact.html) | +----------------------------------------------+ Each box is a single Webpage. Together they form the Website.
A clear understanding of the difference between a webpage and a website is fundamental to web literacy. A webpage is a single document; a website is a cohesive collection of many such documents organised under a domain. This distinction helps in development, communication, and proper planning of web projects. Whether you're building a simple portfolio or a complex e‑commerce platform, knowing where the page ends and the site begins ensures a solid foundation.
जब आप ब्राउज़र खोलकर www.school.edu जैसा पता टाइप करते हैं, तो आपको टेक्स्ट, चित्र और लिंक वाले पृष्ठों का संग्रह दिखता है। फिर भी, लोग अक्सर "वेबपेज" और "वेबसाइट" शब्दों को एक दूसरे के स्थान पर इस्तेमाल करते हैं। उदाहरण के लिए, कोई कह सकता है "मैंने एक वेबपेज बनाया" जबकि उसने कई पृष्ठों वाली पूरी साइट बनाई हो, या एक PDF जैसे एकल दस्तावेज़ को वेबसाइट समझ लिया जाए। यह भ्रम वेब विकास, ग्राहकों से बातचीत और परीक्षा के उत्तरों में गलतफहमियाँ पैदा करता है। समस्या है: वेबसाइट को स्पष्ट रूप से परिभाषित करना और उसे एकल वेबपेज से अलग करना, ताकि हम वेब के बारे में सटीक बात कर सकें और समझ सकें कि वे आपस में कैसे जुड़े हैं।
वेबपेज : वर्ल्ड वाइड वेब पर एक एकल दस्तावेज़ जिसे वेब ब्राउज़र में प्रदर्शित किया जा सकता है। यह HTML में लिखा जाता है और इसमें टेक्स्ट, चित्र, वीडियो, हाइपरलिंक और अन्य तत्व हो सकते हैं। एक वेबपेज की पहचान एक अद्वितीय URL से होती है (जैसे, https://www.example.com/contact.html)।
वेबसाइट : एक ही डोमेन नाम के तहत समूहित संबंधित वेबपेजों का संग्रह। एक वेबसाइट में आमतौर पर एक होमपेज होता है जो अन्य पृष्ठों से लिंक करता है, और सभी पृष्ठ एक समान थीम, नेविगेशन और डिज़ाइन साझा करते हैं। उदाहरण के लिए, www.school.edu एक वेबसाइट है जिसमें /admissions.html, /gallery.html, /contact.html जैसे पृष्ठ शामिल हैं।
• वेबपेज: किसी कंपनी का "हमारे बारे में" पृष्ठ (www.company.com/about) एक एकल वेबपेज है। इसमें कंपनी का इतिहास, मिशन और टीम की तस्वीरें होती हैं।
• वेबसाइट: संपूर्ण www.company.com डोमेन अपने होम, अबाउट, प्रोडक्ट्स, संपर्क पृष्ठों के साथ वेबसाइट है।
• एक किताब के रूप में सोचें: वेबपेज किताब के एक पन्ने जैसा है, जबकि वेबसाइट पूरी किताब है जिसमें आवरण, विषय‑सूची और सभी अध्याय शामिल हैं।
वेबसाइटों को सामग्री, कार्यक्षमता और प्रौद्योगिकी के आधार पर वर्गीकृत किया जा सकता है:
example.com); एक वेबपेज का उस डोमेन के अंतर्गत एक विशिष्ट URL पथ होता है।वेबसाइट: www.school.edu +----------------------------------------------+ | होमपेज (index.html) | | | | | +----> हमारे बारे में (about.html) | | +----> गैलरी (gallery.html) | | +----> संपर्क (contact.html) | +----------------------------------------------+ प्रत्येक बॉक्स एक एकल वेबपेज है। सभी मिलकर वेबसाइट बनाते हैं।
वेबपेज और वेबसाइट के बीच स्पष्ट अंतर समझना वेब साक्षरता की नींव है। वेबपेज एक एकल दस्तावेज़ है; वेबसाइट एक डोमेन के तहत आयोजित ऐसे कई दस्तावेज़ों का सुसंगत संग्रह है। यह अंतर विकास, संचार और वेब परियोजनाओं की उचित योजना में मदद करता है। चाहे आप एक साधारण पोर्टफोलियो बना रहे हों या एक जटिल ई‑कॉमर्स प्लेटफ़ॉर्म, यह जानना कि पृष्ठ कहाँ समाप्त होता है और साइट कहाँ शुरू होती है, एक ठोस आधार सुनिश्चित करता है।
When you visit a website, some pages always show the same content, while others change based on user input or real-time data. You also need to understand where these pages are stored and how they are delivered to your browser. Without this knowledge, you cannot build interactive websites, choose the right hosting plan, or troubleshoot server issues. The problem is: how to distinguish between static and dynamic web pages, understand the role of a web server, and learn the methods of making a website accessible on the internet (hosting).
Static Web Page : A web page with fixed content. It is written entirely in HTML, CSS, and possibly JavaScript that runs only in the browser.
Every visitor sees the exact same information. The page does not interact with a database or server‑side script.
Dynamic Web Page : A web page whose content can change based on user interaction, time, database queries, or other factors.
It is generated on the server using languages like PHP, Python, Node.js, etc., and often pulls data from a database like MySQL.
Web Server : A software (e.g., Apache, Nginx) or a computer that stores website files and delivers them to client browsers over the internet using HTTP/HTTPS.
It processes incoming requests and sends back the appropriate resources (HTML pages, images, etc.). For dynamic pages, it also runs server‑side scripts.
Hosting of a Website : The service of providing space on a server to store the files of a website so that it is accessible via the internet 24/7.
Hosting can be self‑managed (on‑premise) or purchased from a hosting provider (shared, VPS, dedicated, cloud).
• Static Page : A company's "About Us" page that never changes unless the developer manually edits the HTML file.
• Dynamic Page : Your Facebook news feed – it looks different for every user and updates in real time because it's generated from a database.
• Web Server : Apache HTTP Server software running on a computer with IP address 192.168.1.10, serving the website files when someone types the domain name.
• Hosting : A blogger buys a shared hosting plan from Bluehost, uploads WordPress files, and the website becomes live at www.myblog.com.
Types of Web Servers :
Types of Web Hosting :
.html or .htm; content hard‑coded; no server‑side processing; loading speed is very high..php, .aspx, .jsp or no visible extension; content generated per request; require a database connection.
User Browser → Request → Web Server (Apache/Nginx)
│
├── Static file? → send file directly
└── Dynamic request? → pass to PHP/Python
│
v
Application Server
│
v
Database
│
v
Generate HTML → return to Web Server → Browser
Understanding the difference between static and dynamic web pages, the role of a web server, and how hosting works is essential for web development. Static pages are simple and fast, dynamic pages enable modern interactive experiences. A web server delivers content, and hosting provides the infrastructure. Choosing the right combination based on the project's needs ensures performance, security, and scalability.
जब आप किसी वेबसाइट पर जाते हैं, तो कुछ पृष्ठ हमेशा एक जैसी सामग्री दिखाते हैं, जबकि अन्य उपयोगकर्ता के अनुसार या वास्तविक समय में बदलते रहते हैं। आपको यह भी समझना होगा कि ये पृष्ठ कहाँ रखे जाते हैं और ब्राउज़र तक कैसे पहुँचते हैं। इस ज्ञान के बिना, आप इंटरैक्टिव वेबसाइट नहीं बना सकते, सही होस्टिंग योजना नहीं चुन सकते, या सर्वर समस्याओं का निवारण नहीं कर सकते। मुख्य समस्या है: स्थैतिक और गतिशील वेब पृष्ठों में अंतर करना, वेब सर्वर की भूमिका समझना, और वेबसाइट को इंटरनेट पर सुलभ बनाने की विधियाँ (होस्टिंग) सीखना।
स्थैतिक वेब पेज (Static Web Page) : एक ऐसा वेब पृष्ठ जिसकी सामग्री स्थिर होती है। यह केवल HTML, CSS और संभवतः ब्राउज़र में चलने वाली JavaScript में लिखा जाता है।
हर विज़िटर को बिल्कुल एक जैसी जानकारी दिखती है। पृष्ठ किसी डेटाबेस या सर्वर‑साइड स्क्रिप्ट से इंटरैक्ट नहीं करता।
गतिशील वेब पेज (Dynamic Web Page) : ऐसा वेब पृष्ठ जिसकी सामग्री उपयोगकर्ता की क्रिया, समय, डेटाबेस क्वेरी या अन्य कारकों के अनुसार बदल सकती है।
यह सर्वर पर PHP, Python, Node.js आदि भाषाओं का उपयोग करके तैयार होता है और अक्सर MySQL जैसे डेटाबेस से डेटा लेता है।
वेब सर्वर (Web Server) : एक सॉफ़्टवेयर (जैसे Apache, Nginx) या एक कंप्यूटर जो वेबसाइट फ़ाइलों को संग्रहीत करता है और उन्हें HTTP/HTTPS के माध्यम से ग्राहक ब्राउज़र तक पहुँचाता है।
यह आने वाले अनुरोधों को संसाधित करता है और उपयुक्त संसाधन (HTML पृष्ठ, चित्र आदि) वापस भेजता है। गतिशील पृष्ठों के लिए यह सर्वर‑साइड स्क्रिप्ट भी चलाता है।
वेबसाइट होस्टिंग : किसी वेबसाइट की फ़ाइलों को सर्वर पर स्थान प्रदान करने की सेवा ताकि वह इंटरनेट पर 24/7 सुलभ रहे।
होस्टिंग स्वयं प्रबंधित (ऑन‑प्रिमाइसेस) या किसी होस्टिंग प्रदाता से खरीदी जा सकती है (शेयर्ड, VPS, डेडिकेटेड, क्लाउड)।
• स्थैतिक पृष्ठ : किसी कंपनी का "हमारे बारे में" पृष्ठ जो तब तक नहीं बदलता जब तक डेवलपर मैन्युअल रूप से HTML फ़ाइल संपादित न करे।
• गतिशील पृष्ठ : आपका Facebook न्यूज़ फ़ीड – यह हर उपयोगकर्ता के लिए अलग दिखता है और वास्तविक समय में अपडेट होता है क्योंकि यह डेटाबेस से उत्पन्न होता है।
• वेब सर्वर : Apache HTTP सर्वर सॉफ़्टवेयर जो IP पते 192.168.1.10 वाले कंप्यूटर पर चल रहा है, और डोमेन नाम टाइप करने पर वेबसाइट फ़ाइलें प्रस्तुत करता है।
• होस्टिंग : एक ब्लॉगर Bluehost से शेयर्ड होस्टिंग योजना खरीदता है, WordPress फ़ाइलें अपलोड करता है, और वेबसाइट www.myblog.com पर सजीव हो जाती है।
वेब सर्वर के प्रकार :
वेब होस्टिंग के प्रकार :
.html या .htm; सामग्री हार्ड‑कोडेड; कोई सर्वर‑साइड प्रोसेसिंग नहीं; लोडिंग गति बहुत अधिक।.php, .aspx, .jsp या कोई दृश्य एक्सटेंशन नहीं; सामग्री प्रति अनुरोध उत्पन्न होती है; डेटाबेस कनेक्शन की आवश्यकता।
उपयोगकर्ता ब्राउज़र → अनुरोध → वेब सर्वर (Apache/Nginx)
│
├── स्थैतिक फ़ाइल? → सीधे भेजें
└── गतिशील अनुरोध? → PHP/Python को भेजें
│
v
अनुप्रयोग सर्वर
│
v
डेटाबेस
│
v
HTML उत्पन्न करें → वेब सर्वर को लौटाएँ → ब्राउज़र
स्थैतिक और गतिशील वेब पृष्ठों के बीच अंतर, वेब सर्वर की भूमिका और होस्टिंग कैसे काम करती है, यह समझना वेब विकास के लिए आवश्यक है। स्थैतिक पृष्ठ सरल और तेज़ होते हैं, गतिशील पृष्ठ आधुनिक इंटरैक्टिव अनुभव सक्षम करते हैं। वेब सर्वर सामग्री प्रदान करता है और होस्टिंग बुनियादी ढाँचा उपलब्ध कराती है। परियोजना की आवश्यकताओं के अनुसार सही संयोजन चुनने से प्रदर्शन, सुरक्षा और मापनीयता सुनिश्चित होती है।
The internet contains billions of web pages, but a computer cannot display them directly. Users need a tool that can fetch a page from a server, interpret the HTML, CSS, and JavaScript code, and present it in a human‑readable, interactive format. Without such a tool, navigating the web is impossible. Moreover, users want to customise their experience – save passwords, block ads, manage privacy, and keep track of sessions. The problem is: how to provide a user‑friendly application that acts as a gateway to the World Wide Web, offering speed, security, personalisation through settings, extensions, and mechanisms like cookies to remember information. Web browsers solve all of these.
Web Browser : A software application used to access and view websites. It retrieves content from web servers, interprets HTML/CSS/JS, and renders the page on the screen. Examples: Google Chrome, Mozilla Firefox.
Browser Settings : Configurable options within the browser that control privacy (clearing history, cookies), security (pop‑up blocker, safe browsing), appearance (themes, font size), and default behaviours (home page, search engine).
Add‑ons & Plug‑ins : Add‑ons are small programs that extend the browser's functionality (e.g., ad blockers, password managers). Plug‑ins are older technology that handled specific content types (like Flash, Java applets) inside the browser, now largely replaced by native web technologies.
Cookies : Small text files stored on the user's computer by a website. They remember login sessions, shopping cart items, preferences, and tracking information. Cookies are sent back to the server with every request, enabling stateful interaction over the stateless HTTP protocol.
• Browser : You double‑click the Chrome icon and type www.wikipedia.org. The browser fetches the page and displays it.
• Commonly Used Browsers : Google Chrome, Mozilla Firefox, Apple Safari, Microsoft Edge, Opera.
• Settings : In Chrome, going to chrome://settings lets you set the home page, manage saved passwords, clear browsing data, and control site permissions (camera, location).
• Add‑ons : Installing "uBlock Origin" from the Chrome Web Store blocks advertisements and trackers automatically.
• Cookies : After you log into amazon.com, the site sets a cookie. When you revisit, the cookie is sent back, so the site knows you are already authenticated and shows your name.
Types of Browsers :
Types of Add‑ons :
Types of Cookies :
User Interface (address bar, buttons)
│
v
Browser Engine ←→ Rendering Engine (HTML/CSS/JS)
│
v
Networking (HTTP/HTTPS) ←→ Web Server
│
v
Data Storage (Cookies, Cache, LocalStorage)
Cookie Flow:
1. User visits site → Browser sends request
2. Server responds + Set‑Cookie header
3. Browser stores cookie
4. Subsequent requests → Browser sends cookie back
Web browsers are the primary gateway to the internet, transforming raw code into interactive experiences. Understanding their settings, the role of add‑ons, and how cookies work empowers users to browse safely, protect their privacy, and customise their online experience. As web technologies evolve, browsers continue to add new features while balancing speed, security, and usability. Being browser‑literate is as essential as knowing how to search the web itself.
इंटरनेट पर अरबों वेब पेज हैं, लेकिन कंप्यूटर उन्हें सीधे प्रदर्शित नहीं कर सकता। उपयोगकर्ताओं को एक ऐसे उपकरण की ज़रूरत है जो सर्वर से पेज लाए, HTML, CSS और JavaScript कोड को समझे और मानव‑पठनीय, इंटरैक्टिव रूप में प्रस्तुत करे। ऐसे उपकरण के बिना वेब पर जाना असंभव है। इसके अलावा, उपयोगकर्ता अपने अनुभव को अनुकूलित करना चाहते हैं – पासवर्ड सहेजना, विज्ञापन रोकना, गोपनीयता प्रबंधित करना और सत्र याद रखना। समस्या है: एक उपयोगकर्ता‑अनुकूल अनुप्रयोग कैसे प्रदान किया जाए जो वर्ल्ड वाइड वेब का प्रवेशद्वार हो, गति, सुरक्षा, सेटिंग्स के माध्यम से वैयक्तिकरण, एक्सटेंशन और कुकीज़ जैसी क्रियाविधि प्रदान करे। वेब ब्राउज़र इन सभी का समाधान करते हैं।
वेब ब्राउज़र : एक सॉफ़्टवेयर अनुप्रयोग जो वेबसाइटों तक पहुँचने और देखने के लिए उपयोग होता है। यह वेब सर्वरों से सामग्री प्राप्त करता है, HTML/CSS/JS को व्याख्यायित करता है और स्क्रीन पर पृष्ठ प्रस्तुत करता है। उदाहरण: Google Chrome, Mozilla Firefox।
ब्राउज़र सेटिंग्स : ब्राउज़र के भीतर कॉन्फ़िगर किए जा सकने वाले विकल्प जो गोपनीयता (इतिहास, कुकीज़ साफ़ करना), सुरक्षा (पॉप‑अप अवरोधक, सुरक्षित ब्राउज़िंग), रूप (थीम, फ़ॉन्ट आकार) और डिफ़ॉल्ट व्यवहार (होम पेज, खोज इंजन) को नियंत्रित करते हैं।
ऐड‑ऑन और प्लग‑इन : ऐड‑ऑन छोटे प्रोग्राम हैं जो ब्राउज़र की कार्यक्षमता बढ़ाते हैं (जैसे विज्ञापन अवरोधक, पासवर्ड प्रबंधक)। प्लग‑इन पुरानी तकनीक है जो ब्राउज़र के अंदर विशिष्ट सामग्री (जैसे Flash, Java एप्लेट) को संभालती थी, अब इसे मूल वेब तकनीकों ने बदल दिया है।
कुकीज़ : वेबसाइट द्वारा उपयोगकर्ता के कंप्यूटर पर संग्रहीत छोटी टेक्स्ट फ़ाइलें। ये लॉगिन सत्र, शॉपिंग कार्ट आइटम, प्राथमिकताएँ और ट्रैकिंग जानकारी याद रखती हैं। HTTP प्रोटोकॉल के स्टेटलेस होने के बावजूद, हर अनुरोध के साथ कुकीज़ सर्वर को वापस भेजी जाती हैं, जिससे स्टेटफुल इंटरैक्शन संभव होता है।
• ब्राउज़र : आप Chrome आइकन पर डबल‑क्लिक करते हैं और www.wikipedia.org टाइप करते हैं। ब्राउज़र पृष्ठ लाकर प्रदर्शित करता है।
• सामान्य ब्राउज़र : Google Chrome, Mozilla Firefox, Apple Safari, Microsoft Edge, Opera।
• सेटिंग्स : Chrome में chrome://settings पर जाकर आप होम पेज सेट कर सकते हैं, सहेजे गए पासवर्ड प्रबंधित कर सकते हैं, ब्राउज़िंग डेटा साफ़ कर सकते हैं और साइट अनुमतियाँ (कैमरा, स्थान) नियंत्रित कर सकते हैं।
• ऐड‑ऑन : Chrome वेब स्टोर से "uBlock Origin" इंस्टॉल करने पर यह स्वचालित रूप से विज्ञापन और ट्रैकर्स रोकता है।
• कुकीज़ : amazon.in में लॉगिन करने के बाद, साइट एक कुकी सेट करती है। जब आप दोबारा आते हैं, तो कुकी वापस भेजी जाती है, जिससे साइट जान जाती है कि आप पहले से प्रमाणित हैं और आपका नाम दिखाती है।
ब्राउज़र के प्रकार :
ऐड‑ऑन के प्रकार :
कुकीज़ के प्रकार :
उपयोगकर्ता इंटरफ़ेस (पता पट्टी, बटन)
│
v
ब्राउज़र इंजन ←→ रेंडरिंग इंजन (HTML/CSS/JS)
│
v
नेटवर्किंग (HTTP/HTTPS) ←→ वेब सर्वर
│
v
डेटा भंडारण (कुकीज़, कैश, LocalStorage)
कुकी प्रवाह:
1. उपयोगकर्ता साइट पर जाता है → ब्राउज़र अनुरोध भेजता है
2. सर्वर प्रतिक्रिया + Set‑Cookie हेडर देता है
3. ब्राउज़र कुकी संग्रहीत करता है
4. बाद के अनुरोध → ब्राउज़र कुकी वापस भेजता है
वेब ब्राउज़र इंटरनेट के प्राथमिक प्रवेशद्वार हैं, जो कच्चे कोड को इंटरैक्टिव अनुभवों में बदलते हैं। उनकी सेटिंग्स, ऐड‑ऑन की भूमिका और कुकीज़ के कार्य को समझना उपयोगकर्ताओं को सुरक्षित ब्राउज़ करने, अपनी गोपनीयता की रक्षा करने और अपने ऑनलाइन अनुभव को अनुकूलित करने में सशक्त बनाता है। जैसे‑जैसे वेब प्रौद्योगिकियाँ विकसित होती हैं, ब्राउज़र गति, सुरक्षा और उपयोगिता में संतुलन बनाते हुए नई सुविधाएँ जोड़ते रहते हैं। ब्राउज़र‑साक्षर होना उतना ही आवश्यक है जितना स्वयं वेब पर खोज करना।
Before the internet age, a person’s daily activities left few permanent traces. Today, almost every online action — visiting a website, liking a post, making a purchase, or even just walking with a smartphone — creates a digital record. This trail accumulates silently, often without the user's full awareness or consent. Companies, governments, and even strangers can use these traces to build detailed profiles of individuals. The core problem is: how to understand and manage this vast, invisible trail of data that we leave behind in the digital world, balancing the benefits of connectivity with the need for privacy and security. This trail is called a digital footprint.
Digital Footprint : The unique set of digital traces and records that a person leaves behind when they use the internet or digital devices. It includes all the data generated by an individual’s online activities and can be broadly divided into two types: active digital footprint (information deliberately shared, like social media posts and emails) and passive digital footprint (data collected without direct intention, such as browsing history, IP address, and location data gathered by websites and apps).
• Active footprint : A student posts a photo on Instagram, writes a comment on YouTube, fills out an online form, or sends an email.
• Passive footprint : A shopping website logs the IP address from which you connected, tracks the pages you viewed, or uses cookies to record how long you stayed on a product page. Even a like or a share that you did not initiate directly may be part of your passive footprint.
Digital footprints are classified based on how the data is created:
Active Actions
(post, comment, email, form)
│
v
+------------+
| Digital |
| Footprint |
+-----+------+
^
│
Passive Tracking
(cookies, IP, location, clicks)
Active inputs and passive tracking combine to form a person's digital footprint.
Your digital footprint is like a permanent shadow in the digital world. It can open doors to personalised services and connections, but it also carries significant risks to privacy and security. By understanding the types of footprint, their characteristics, and how they are created, you can make informed choices about what you share, how you configure your devices, and how you manage your online reputation. In an increasingly data‑driven society, digital footprint literacy is not optional — it is essential.
इंटरनेट युग से पहले, व्यक्ति की दैनिक गतिविधियाँ बहुत कम स्थायी निशान छोड़ती थीं। आज, लगभग हर ऑनलाइन क्रिया — किसी वेबसाइट पर जाना, पोस्ट पसंद करना, खरीदारी करना, या स्मार्टफ़ोन के साथ चलना भी — एक डिजिटल रिकॉर्ड बनाती है। यह निशान चुपचाप जमा होता जाता है, अक्सर उपयोगकर्ता की पूरी जागरूकता या सहमति के बिना। कंपनियाँ, सरकारें और अनजान लोग भी इन निशानों का उपयोग करके व्यक्तियों की विस्तृत प्रोफ़ाइल बना सकते हैं। मुख्य समस्या है: डिजिटल दुनिया में हमारे पीछे छूटने वाले विशाल, अदृश्य डेटा के निशान को कैसे समझा और प्रबंधित किया जाए, जुड़ाव के लाभों को गोपनीयता और सुरक्षा की आवश्यकता के साथ संतुलित करते हुए। इस निशान को डिजिटल फ़ुटप्रिंट कहते हैं।
डिजिटल फ़ुटप्रिंट : डिजिटल निशानों और रिकॉर्डों का वह अनूठा समूह जो कोई व्यक्ति इंटरनेट या डिजिटल उपकरणों का उपयोग करते समय पीछे छोड़ता है। इसमें व्यक्ति की ऑनलाइन गतिविधियों द्वारा उत्पन्न सारा डेटा शामिल है और इसे मोटे तौर पर दो प्रकारों में बाँटा जा सकता है: सक्रिय डिजिटल फ़ुटप्रिंट (जानबूझकर साझा की गई जानकारी, जैसे सोशल मीडिया पोस्ट और ईमेल) और निष्क्रिय डिजिटल फ़ुटप्रिंट (बिना प्रत्यक्ष इरादे के एकत्रित डेटा, जैसे ब्राउज़िंग इतिहास, IP पता, और वेबसाइटों व ऐप्स द्वारा जुटाया गया स्थान डेटा)।
• सक्रिय फ़ुटप्रिंट : एक छात्र Instagram पर फ़ोटो पोस्ट करता है, YouTube पर टिप्पणी लिखता है, ऑनलाइन फ़ॉर्म भरता है या ईमेल भेजता है।
• निष्क्रिय फ़ुटप्रिंट : एक खरीदारी वेबसाइट आपके IP पते को लॉग करती है, आपके द्वारा देखे गए पृष्ठों को ट्रैक करती है, या कुकीज़ के माध्यम से रिकॉर्ड करती है कि आपने किसी उत्पाद पृष्ठ पर कितनी देर बिताई। यहाँ तक कि आपके द्वारा सीधे शुरू न किया गया कोई लाइक या शेयर भी आपके निष्क्रिय फ़ुटप्रिंट का हिस्सा हो सकता है।
डिजिटल फ़ुटप्रिंट को डेटा निर्माण के आधार पर वर्गीकृत किया जाता है:
सक्रिय क्रियाएँ
(पोस्ट, टिप्पणी, ईमेल, फ़ॉर्म)
│
v
+------------+
| डिजिटल |
| फ़ुटप्रिंट |
+-----+------+
^
│
निष्क्रिय ट्रैकिंग
(कुकीज़, IP, स्थान, क्लिक)
सक्रिय इनपुट और निष्क्रिय ट्रैकिंग मिलकर किसी व्यक्ति का डिजिटल फ़ुटप्रिंट बनाते हैं।
आपका डिजिटल फ़ुटप्रिंट डिजिटल दुनिया में एक स्थायी छाया के समान है। यह वैयक्तिकृत सेवाओं और जुड़ाव के द्वार खोल सकता है, लेकिन यह गोपनीयता और सुरक्षा के लिए महत्वपूर्ण जोखिम भी रखता है। फ़ुटप्रिंट के प्रकारों, उनकी विशेषताओं और वे कैसे बनते हैं, को समझकर आप जो साझा करते हैं, अपनी डिवाइस सेटिंग्स और ऑनलाइन प्रतिष्ठा के प्रबंधन के बारे में सूचित निर्णय ले सकते हैं। तेज़ी से डेटा‑संचालित होती सोसाइटी में, डिजिटल फ़ुटप्रिंट साक्षरता वैकल्पिक नहीं — आवश्यक है।
The internet and digital communication allow us to interact instantly with anyone in the world. However, the absence of face‑to‑face contact often leads to misunderstandings, offensive language, and inappropriate behaviour. Emails sent in anger, all‑caps messages that appear as shouting, or sharing someone’s private information without consent damage relationships and reputations. Without a set of agreed rules for online behaviour, the digital world becomes chaotic and hostile. The core problem is: how to communicate respectfully, clearly, and safely in the digital environment, ensuring that our words and actions do not harm others or ourselves. Net and communication etiquettes address exactly this gap.
Net Etiquette (Netiquette) : A set of guidelines for acceptable and respectful behaviour when communicating over the internet. It covers all forms of online interaction — email, chat, social media, forums, video calls, etc.
Communication Etiquette : Broader rules of polite and effective communication that apply to both online and offline contexts. When combined with netiquette, they ensure that messages are clear, courteous, and appropriate for the medium.
• Good Netiquette : Writing a clear subject line in an email, using proper greetings and closings, not forwarding chain messages, and asking permission before tagging someone in a photo.
• Bad Netiquette : Typing in ALL CAPITAL LETTERS (interpreted as shouting), posting embarrassing pictures of friends without consent, using profanity in public forums, or spamming group chats with irrelevant messages.
+---------------------------------------------------+ | NET & COMMUNICATION ETIQUETTES | +---------------------------------------------------+ | Respect | Clarity | Privacy | Empathy | | (be kind, | (no caps, | (ask before| (think of | | no flame)| concise) | sharing) | the person)| +---------------------------------------------------+ | Accountability | Context-awareness | Security | | (own words) | (platform matters)| (don't | | | | share | | | | malware) | +---------------------------------------------------+
These pillars form the foundation of respectful online interaction.
Net and communication etiquettes are not just a set of rules — they are the foundation of a healthy digital society. By being mindful of how we write, what we share, and how we respond, we create a safer, more respectful internet for everyone. These guidelines are especially important for students who are active on social media, online learning platforms, and collaborative tools. Practising good netiquette is a lifelong skill that enhances both personal and professional life.
इंटरनेट और डिजिटल संचार हमें दुनिया में किसी से भी तुरंत बात करने की अनुमति देते हैं। लेकिन आमने‑सामने के संपर्क की कमी से अक्सर गलतफहमियाँ, अपमानजनक भाषा और अनुचित व्यवहार होता है। गुस्से में भेजे गए ईमेल, पूरे बड़े अक्षरों में लिखे संदेश (जो चिल्लाने जैसे लगते हैं), या बिना अनुमति के किसी की निजी जानकारी साझा करना रिश्तों और प्रतिष्ठा को नुकसान पहुँचाता है। ऑनलाइन व्यवहार के लिए सहमत नियमों के बिना, डिजिटल दुनिया अराजक और शत्रुतापूर्ण हो जाती है। मुख्य समस्या है: डिजिटल वातावरण में सम्मानपूर्वक, स्पष्ट और सुरक्षित रूप से कैसे संवाद करें, ताकि हमारे शब्द और कार्य दूसरों या स्वयं को नुकसान न पहुँचाएँ। नेट और संचार शिष्टाचार इसी कमी को पूरा करते हैं।
नेट शिष्टाचार (Netiquette) : इंटरनेट पर संवाद करते समय स्वीकार्य और सम्मानजनक व्यवहार के लिए दिशानिर्देशों का एक समूह। यह ऑनलाइन संवाद के सभी रूपों — ईमेल, चैट, सोशल मीडिया, फ़ोरम, वीडियो कॉल आदि को कवर करता है।
संचार शिष्टाचार : विनम्र और प्रभावी संचार के व्यापक नियम जो ऑनलाइन और ऑफलाइन दोनों संदर्भों में लागू होते हैं। नेटिकेट के साथ मिलकर, यह सुनिश्चित करते हैं कि संदेश माध्यम के अनुरूप स्पष्ट, शिष्ट और उपयुक्त हों।
• अच्छा नेटिकेट : ईमेल में स्पष्ट विषय पंक्ति लिखना, उचित अभिवादन और समापन का उपयोग करना, चेन संदेश अग्रेषित न करना, और किसी को फ़ोटो में टैग करने से पहले अनुमति लेना।
• खराब नेटिकेट : सभी बड़े अक्षरों में टाइप करना (चिल्लाने के रूप में देखा जाता है), बिना सहमति के दोस्तों की शर्मनाक तस्वीरें पोस्ट करना, सार्वजनिक मंचों पर अभद्र भाषा का प्रयोग, या अप्रासंगिक संदेशों से ग्रुप चैट को स्पैम करना।
+---------------------------------------------------+ | नेट और संचार शिष्टाचार | +---------------------------------------------------+ | सम्मान | स्पष्टता | गोपनीयता | सहानुभूति | | (दयालु, | (बड़े अक्षर | (साझा करने | (व्यक्ति के | | फ्लेम नहीं)| संक्षिप्त) | से पूछें) | बारे में | | | | | सोचें) | +---------------------------------------------------+ | जवाबदेही | संदर्भ‑जागरूकता | सुरक्षा | | (अपने शब्दों | (प्लेटफ़ॉर्म का | (मैलवेयर | | की जिम्मेदारी)| महत्व) | न फैलाएँ) | +---------------------------------------------------+
ये स्तंभ सम्मानजनक ऑनलाइन संवाद की नींव बनाते हैं।
नेट और संचार शिष्टाचार केवल नियमों का समूह नहीं हैं — ये एक स्वस्थ डिजिटल समाज की नींव हैं। हम कैसे लिखते हैं, क्या साझा करते हैं और कैसे प्रतिक्रिया देते हैं, इसके प्रति सचेत रहकर हम सभी के लिए एक सुरक्षित, अधिक सम्मानजनक इंटरनेट बनाते हैं। ये दिशानिर्देश विशेष रूप से उन छात्रों के लिए महत्वपूर्ण हैं जो सोशल मीडिया, ऑनलाइन लर्निंग प्लेटफ़ॉर्म और सहयोगी उपकरणों पर सक्रिय हैं। अच्छा नेटिकेट अपनाना एक आजीवन कौशल है जो व्यक्तिगत और पेशेवर जीवन दोनों को बढ़ाता है।
In today's digital world, vast amounts of personal and business data are created, stored, and shared every second. This data can be misused if it falls into the wrong hands – leading to identity theft, financial fraud, privacy breaches, and loss of reputation. At the same time, creative works, inventions, and brand identities can be copied or stolen without the owner's permission, discouraging innovation and damaging businesses. The core problem is: how to legally and ethically protect personal information from misuse, and how to secure the rights of creators over their original works and inventions. Data Protection laws and Intellectual Property Rights (IPR) provide the framework to address these challenges.
Data Protection : The set of laws, policies, and practices designed to safeguard personal and sensitive information
from unauthorized access, misuse, disclosure, or destruction. It ensures that data is collected fairly, used only for stated purposes,
and kept secure. Example: GDPR (General Data Protection Regulation) in the European Union.
Intellectual Property Rights (IPR) : Legal rights granted to creators and owners of original intellectual works.
They give the owner exclusive rights to use, reproduce, and profit from their creations for a certain period.
IPR covers intangible assets like inventions, literary/artistic works, designs, symbols, and names used in commerce.
• Data Protection : A hospital must protect patients' medical records. Only authorized doctors should see them,
and the hospital cannot sell patient data to advertisers. GDPR fines companies that fail to protect such data.
• IPR – Copyright : A songwriter automatically holds copyright over their song. No one else can perform or sell copies without permission.
• IPR – Patent : An inventor who designs a new fuel‑efficient engine gets a patent, preventing others from making or selling that engine for 20 years.
• IPR – Trademark : The Nike “swoosh” logo is a registered trademark; other shoe companies cannot use a confusingly similar logo.
Data Protection categories :
Types of Intellectual Property Rights :
Data Protection :
IPR :
+-----------------------------------------------------+ | LEGAL PROTECTION FRAMEWORK | +------------------------+----------------------------+ | DATA PROTECTION | INTELLECTUAL PROPERTY | | (personal data) | (creations of mind) | +------------------------+----------------------------+ | - Privacy laws | - Copyright (art, music) | | - Security measures | - Patent (inventions) | | - Consent management | - Trademark (logos, names)| | - Breach notification | - Trade Secret (formulas) | +------------------------+----------------------------+
Data Protection and Intellectual Property Rights are two pillars of the modern digital economy. Data Protection ensures that individuals' privacy is respected in an era of big data and AI, while IPR rewards and protects the creators who drive cultural and technological progress. Both are evolving fields, requiring awareness and compliance from individuals, businesses, and governments.
आज की डिजिटल दुनिया में, हर सेकंड भारी मात्रा में व्यक्तिगत और व्यावसायिक डेटा बनाया, संग्रहीत और साझा किया जाता है। अगर यह डेटा गलत हाथों में पड़ जाए तो इसका दुरुपयोग हो सकता है – पहचान चोरी, वित्तीय धोखाधड़ी, गोपनीयता भंग और प्रतिष्ठा की हानि। साथ ही, रचनात्मक कार्यों, आविष्कारों और ब्रांड पहचान को बिना मालिक की अनुमति के कॉपी या चुराया जा सकता है, जिससे नवाचार हतोत्साहित होता है और व्यवसायों को नुकसान होता है। मुख्य समस्या है: व्यक्तिगत जानकारी को दुरुपयोग से कानूनी और नैतिक रूप से कैसे बचाया जाए, और रचनाकारों के उनके मूल कार्यों और आविष्कारों पर अधिकार कैसे सुरक्षित किए जाएँ। डेटा संरक्षण कानून और बौद्धिक संपदा अधिकार (IPR) इन चुनौतियों का समाधान प्रदान करते हैं।
डेटा संरक्षण (Data Protection) : व्यक्तिगत और संवेदनशील जानकारी को अनधिकृत पहुँच, दुरुपयोग, प्रकटीकरण या विनाश से बचाने के लिए बनाए गए कानूनों, नीतियों और प्रथाओं का समूह।
यह सुनिश्चित करता है कि डेटा निष्पक्ष रूप से एकत्र किया जाए, केवल बताए गए उद्देश्यों के लिए उपयोग किया जाए और सुरक्षित रखा जाए।
उदाहरण: यूरोपीय संघ में GDPR (सामान्य डेटा संरक्षण विनियम)।
बौद्धिक संपदा अधिकार (IPR) : मूल बौद्धिक कार्यों के रचनाकारों और स्वामियों को दिए गए कानूनी अधिकार।
ये मालिक को एक निश्चित अवधि के लिए अपनी रचनाओं का उपयोग, पुनरुत्पादन और लाभ कमाने का विशेष अधिकार देते हैं।
IPR में आविष्कार, साहित्यिक/कलात्मक कार्य, डिज़ाइन, प्रतीक और वाणिज्य में उपयोग होने वाले नाम शामिल हैं।
• डेटा संरक्षण : एक अस्पताल को मरीज़ों के मेडिकल रिकॉर्ड की सुरक्षा करनी होगी। केवल अधिकृत डॉक्टर ही उन्हें देख सकते हैं,
और अस्पताल विज्ञापनदाताओं को रोगी डेटा नहीं बेच सकता। GDPR ऐसे डेटा की सुरक्षा करने में विफल कंपनियों पर जुर्माना लगाता है।
• IPR – कॉपीराइट : एक गीतकार को अपने गाने पर स्वचालित रूप से कॉपीराइट प्राप्त होता है। कोई और बिना अनुमति के इसे प्रस्तुत या बेच नहीं सकता।
• IPR – पेटेंट : एक नए ईंधन‑कुशल इंजन का आविष्कारक पेटेंट प्राप्त करता है, जो 20 वर्षों तक दूसरों को उस इंजन को बनाने या बेचने से रोकता है।
• IPR – ट्रेडमार्क : Nike का "स्वूश" लोगो पंजीकृत ट्रेडमार्क है; अन्य जूता कंपनियाँ भ्रामक रूप से समान लोगो का उपयोग नहीं कर सकतीं।
डेटा संरक्षण की श्रेणियाँ :
बौद्धिक संपदा अधिकार के प्रकार :
डेटा संरक्षण :
IPR :
+-----------------------------------------------------+ | कानूनी संरक्षण ढाँचा | +------------------------+----------------------------+ | डेटा संरक्षण | बौद्धिक संपदा अधिकार | | (व्यक्तिगत डेटा) | (मन की रचनाएँ) | +------------------------+----------------------------+ | - गोपनीयता कानून | - कॉपीराइट (कला, संगीत) | | - सुरक्षा उपाय | - पेटेंट (आविष्कार) | | - सहमति प्रबंधन | - ट्रेडमार्क (लोगो, नाम) | | - उल्लंघन अधिसूचना | - व्यापार रहस्य (सूत्र) | +------------------------+----------------------------+
डेटा संरक्षण और बौद्धिक संपदा अधिकार आधुनिक डिजिटल अर्थव्यवस्था के दो स्तंभ हैं। डेटा संरक्षण सुनिश्चित करता है कि बिग डेटा और AI के युग में व्यक्तियों की गोपनीयता का सम्मान हो, जबकि IPR उन रचनाकारों को पुरस्कृत और संरक्षित करता है जो सांस्कृतिक और तकनीकी प्रगति को आगे बढ़ाते हैं। दोनों विकसित होते क्षेत्र हैं, जिनमें व्यक्तियों, व्यवसायों और सरकारों से जागरूकता और अनुपालन की आवश्यकता है।
In the age of the internet, text, images, music, videos, software, and ideas can be copied and shared with a single click. Many people reuse these materials without giving credit to the original creator or without understanding the legal rights attached to them. This leads to ethical violations, legal disputes, loss of reputation, and discouragement of innovation. The core problem is: how to respect the intellectual efforts of others by avoiding plagiarism, understanding the legal framework of copyright, and properly using licenses to share and use creative works.
Plagiarism : The act of using someone else’s words, ideas, or creations without proper acknowledgment, presenting them as your own. It is an ethical offense, not necessarily a legal one, though it may overlap with copyright infringement.
Copyright : A legal right granted to the creator of an original work (literary, artistic, musical, dramatic, software, etc.) that gives them exclusive rights over its reproduction, distribution, adaptation, and public performance for a limited period. Copyright is automatic upon creation; registration is not mandatory but helps in enforcement.
Licensing : A permission granted by the copyright owner (licensor) to another party (licensee) to use the work under specific terms and conditions. A license defines what you can and cannot do with the work—for example, whether you can modify it, share it, or use it commercially.
• Plagiarism : A student copies two paragraphs from an online article into their school project without using quotation marks or citing the source.
• Copyright : A photographer automatically owns the copyright of a picture they clicked. A newspaper cannot publish that picture without the photographer's permission.
• Licensing : A programmer writes a useful utility and releases it under the MIT License. Now anyone can use, modify, and distribute the code freely as long as they include the original copyright notice.
Types of Plagiarism :
Types of Copyright (categories of works) :
Types of Licenses (commonly used) :
Plagiarism :
Copyright :
Licensing :
+--------------------------+
| ORIGINAL WORK |
+--------------------------+
|
| automatically protected by
v
+-------------------+
| COPYRIGHT | (legal right of creator)
+-------------------+
| |
| | owner may grant
| v
| +-------------------+
| | LICENSE | (permission to use)
| +-------------------+
|
v
+-------------------+
| PLAGIARISM | (using without credit – ethical breach)
+-------------------+
(may also infringe copyright if work is protected)
Plagiarism, copyright, and licensing are three interconnected concepts that govern how we create, share, and use intellectual work. Plagiarism is about ethics and honesty; copyright is the law that protects creators; licensing is the tool that allows legal sharing and collaboration. Understanding all three is essential for students, researchers, developers, and artists to work responsibly and avoid legal and academic pitfalls.
इंटरनेट के युग में टेक्स्ट, चित्र, संगीत, वीडियो, सॉफ़्टवेयर और विचारों को एक क्लिक से कॉपी और साझा किया जा सकता है। बहुत से लोग बिना मूल रचनाकार को श्रेय दिए या उससे जुड़े कानूनी अधिकारों को समझे इनका पुन: उपयोग करते हैं। इससे नैतिक उल्लंघन, कानूनी विवाद, प्रतिष्ठा की हानि और नवाचार हतोत्साहन होता है। मुख्य समस्या है: साहित्यिक चोरी से बचकर, कॉपीराइट के कानूनी ढाँचे को समझकर और रचनात्मक कार्यों को साझा व उपयोग करने के लिए उचित लाइसेंसों का उपयोग करके दूसरों के बौद्धिक प्रयासों का सम्मान कैसे किया जाए।
साहित्यिक चोरी (Plagiarism) : किसी अन्य के शब्दों, विचारों या रचनाओं को बिना उचित स्वीकारोक्ति के अपने नाम से प्रस्तुत करना। यह एक नैतिक अपराध है, जरूरी नहीं कि कानूनी, हालाँकि यह कॉपीराइट उल्लंघन से ओवरलैप हो सकता है।
कॉपीराइट (Copyright) : मूल रचना (साहित्यिक, कलात्मक, संगीत, नाटकीय, सॉफ़्टवेयर आदि) के रचनाकार को दिया गया एक कानूनी अधिकार जो उसे एक सीमित समय के लिए पुनरुत्पादन, वितरण, रूपांतरण और सार्वजनिक प्रदर्शन का विशेष अधिकार देता है। कॉपीराइट रचना के साथ स्वचालित रूप से उत्पन्न होता है; पंजीकरण अनिवार्य नहीं किंतु प्रवर्तन में सहायक होता है।
लाइसेंसिंग (Licensing) : कॉपीराइट स्वामी (लाइसेंसर) द्वारा किसी अन्य पक्ष (लाइसेंसधारी) को विशिष्ट नियमों व शर्तों के तहत कार्य का उपयोग करने की अनुमति। लाइसेंस यह परिभाषित करता है कि आप कार्य के साथ क्या कर सकते हैं—जैसे संशोधन करना, वाणिज्यिक उपयोग, साझा करना आदि।
• साहित्यिक चोरी : एक छात्र अपने प्रोजेक्ट में किसी ऑनलाइन लेख से दो अनुच्छेद बिना उद्धरण चिह्न या स्रोत उल्लेख के कॉपी कर लेता है।
• कॉपीराइट : एक फ़ोटोग्राफ़र द्वारा खींची गई तस्वीर पर स्वतः उसका कॉपीराइट होता है। कोई समाचार पत्र बिना अनुमति के वह तस्वीर प्रकाशित नहीं कर सकता।
• लाइसेंसिंग : एक प्रोग्रामर एक उपयोगी टूल बनाता है और उसे MIT लाइसेंस के तहत जारी करता है। अब कोई भी कोड का उपयोग, संशोधन और वितरण स्वतंत्र रूप से कर सकता है, बशर्ते मूल कॉपीराइट नोटिस शामिल किया जाए।
साहित्यिक चोरी के प्रकार :
कॉपीराइट के प्रकार (कार्यों की श्रेणियाँ) :
लाइसेंस के प्रकार (प्रमुख) :
साहित्यिक चोरी :
कॉपीराइट :
लाइसेंसिंग :
+--------------------------+
| मूल रचना |
+--------------------------+
|
| स्वचालित रूप से संरक्षित
v
+-------------------+
| कॉपीराइट | (रचनाकार का कानूनी अधिकार)
+-------------------+
| |
| | स्वामी अनुदान दे सकता है
| v
| +-------------------+
| | लाइसेंस | (उपयोग की अनुमति)
| +-------------------+
|
v
+-------------------+
| साहित्यिक चोरी | (श्रेयरहित उपयोग – नैतिक उल्लंघन)
+-------------------+
(यदि रचना संरक्षित है तो कॉपीराइट का भी उल्लंघन हो सकता है)
साहित्यिक चोरी, कॉपीराइट और लाइसेंसिंग तीन परस्पर जुड़ी अवधारणाएँ हैं जो यह नियंत्रित करती हैं कि हम बौद्धिक कार्य कैसे बनाएँ, साझा करें और उपयोग करें। साहित्यिक चोरी नैतिकता और ईमानदारी से संबंधित है; कॉपीराइट वह कानून है जो रचनाकारों की रक्षा करता है; लाइसेंसिंग वह उपकरण है जो कानूनी साझाकरण और सहयोग की अनुमति देता है। छात्रों, शोधकर्ताओं, डेवलपर्स और कलाकारों के लिए जिम्मेदारी से काम करने और कानूनी व शैक्षणिक नुकसान से बचने हेतु तीनों को समझना अनिवार्य है।
Traditional proprietary software (like Microsoft Windows, Adobe Photoshop) comes with restrictions: you cannot view or modify its source code, you must buy expensive licenses, and you often cannot share it with others. This limits learning, innovation, and access, especially for students, small businesses, and developing countries. The core problem is: how to create software that respects users' freedom to use, study, modify, and share it, while also encouraging community collaboration and transparency. Free and Open-Source Software (FOSS) was born to solve exactly this.
Free and Open-Source Software (FOSS) : Software that is both free (as in freedom, not necessarily price) and open-source. It grants users four essential freedoms:
• Linux : A free and open-source operating system kernel, used by millions (Ubuntu, Android, servers).
• LibreOffice : A free office suite (word processor, spreadsheet, presentation) alternative to Microsoft Office.
• Mozilla Firefox : An open-source web browser.
• GIMP : A powerful image editing tool, similar to Adobe Photoshop.
• Python : The programming language itself is open-source; anyone can view its source code and contribute.
FOSS can be categorized based on the licenses used, which define how the software can be used, modified, and shared:
+---------------------------------------------+ | FOSS | +---------------------------------------------+ | Free Software Open Source | | (freedom focus) (practical focus) | +------------------------+--------------------+ | Four Freedoms + Open Code | +---------------------------------------------+ | Community Collaboration | +---------------------------------------------+ | Licenses: GPL (copyleft), MIT (permissive) | +---------------------------------------------+
FOSS represents a paradigm shift in how software is created and distributed. It empowers users, fosters global collaboration, and drives technological innovation. While it has its challenges, the benefits of transparency, cost savings, and community support make it an essential part of the modern digital ecosystem. Understanding FOSS and its principles is vital for anyone pursuing a career in technology.
पारंपरिक मालिकाना सॉफ़्टवेयर (जैसे Microsoft Windows, Adobe Photoshop) प्रतिबंधों के साथ आता है: आप इसका स्रोत कोड नहीं देख सकते या बदल नहीं सकते, महँगे लाइसेंस खरीदने पड़ते हैं, और अक्सर इसे दूसरों के साथ साझा नहीं कर सकते। इससे सीखना, नवाचार और पहुँच सीमित होती है, विशेषकर छात्रों, छोटे व्यवसायों और विकासशील देशों के लिए। मुख्य समस्या है: ऐसा सॉफ़्टवेयर कैसे बनाया जाए जो उपयोगकर्ताओं की उपयोग, अध्ययन, संशोधन और साझा करने की स्वतंत्रता का सम्मान करे, साथ ही सामुदायिक सहयोग और पारदर्शिता को प्रोत्साहित करे। मुफ़्त और ओपन-सोर्स सॉफ़्टवेयर (FOSS) इसी समस्या के समाधान के लिए उत्पन्न हुआ।
मुफ़्त और ओपन-सोर्स सॉफ़्टवेयर (FOSS) : ऐसा सॉफ़्टवेयर जो स्वतंत्र (आज़ादी, ज़रूरी नहीं कि मुफ़्त) और ओपन-सोर्स दोनों हो। यह उपयोगकर्ताओं को चार आवश्यक स्वतंत्रताएँ देता है:
• Linux : एक मुफ़्त और ओपन-सोर्स ऑपरेटिंग सिस्टम कर्नेल, जो करोड़ों उपकरणों (Ubuntu, Android, सर्वर) में उपयोग होता है।
• LibreOffice : एक मुफ़्त ऑफ़िस सूट (वर्ड प्रोसेसर, स्प्रेडशीट, प्रेज़ेंटेशन), Microsoft Office का विकल्प।
• Mozilla Firefox : एक ओपन-सोर्स वेब ब्राउज़र।
• GIMP : एक शक्तिशाली चित्र संपादन उपकरण, Adobe Photoshop के समान।
• Python : प्रोग्रामिंग भाषा स्वयं ओपन-सोर्स है; कोई भी इसका स्रोत कोड देख और योगदान कर सकता है।
FOSS को लाइसेंसों के आधार पर वर्गीकृत किया जा सकता है, जो यह परिभाषित करते हैं कि सॉफ़्टवेयर का उपयोग, संशोधन और साझाकरण कैसे किया जा सकता है:
+---------------------------------------------+ | FOSS | +---------------------------------------------+ | मुफ़्त सॉफ़्टवेयर ओपन सोर्स | | (स्वतंत्रता पर बल) (व्यावहारिकता) | +------------------------+--------------------+ | चार स्वतंत्रताएँ + खुला कोड | +---------------------------------------------+ | सामुदायिक सहयोग | +---------------------------------------------+ | लाइसेंस: GPL (कॉपीलेफ़्ट), MIT (अनुमतिप्रद) | +---------------------------------------------+
FOSS सॉफ़्टवेयर बनाने और वितरित करने के तरीके में एक क्रांतिकारी बदलाव का प्रतिनिधित्व करता है। यह उपयोगकर्ताओं को सशक्त बनाता है, वैश्विक सहयोग को बढ़ावा देता है और तकनीकी नवाचार को संचालित करता है। हालाँकि इसकी अपनी चुनौतियाँ हैं, पारदर्शिता, लागत बचत और सामुदायिक समर्थन के लाभ इसे आधुनिक डिजिटल पारिस्थितिकी तंत्र का एक अनिवार्य हिस्सा बनाते हैं। प्रौद्योगिकी में करियर बनाने वाले किसी भी व्यक्ति के लिए FOSS और इसके सिद्धांतों को समझना अनिवार्य है।
The internet has become an integral part of our lives, but it also exposes us to various digital threats. Criminals use technology to steal personal data, money, and identities. Individuals, businesses, and even governments face attacks like unauthorised computer access, fraudulent emails, and online harassment. The anonymity and global reach of the internet make it difficult to track and stop these offenders. The core problem is: how to protect individuals and organisations from criminal activities carried out using computers and the internet, and how to establish legal frameworks to prevent, detect, and punish such crimes. This has given rise to the fields of cybercrime, cybersecurity, and cyber laws.
Cybercrime : Any illegal activity that involves a computer, a network, or a digital device. It can target individuals (identity theft, online fraud), property (hacking, virus attacks), or governments (cyber terrorism).
Cyber Laws : The legal provisions that govern the use of the internet and digital communication. They define what constitutes a cybercrime and prescribe penalties. Example: India's Information Technology Act, 2000 (IT Act).
Hacking : Unauthorised access to a computer system or network. It can be ethical (with permission for security testing) or unethical/malicious (to steal, damage, or disrupt). Black‑hat hackers engage in crime; white‑hat hackers help secure systems.
Phishing : A type of cyber fraud where attackers send deceptive emails or messages that appear to come from a trusted source (like a bank or a social media site) to trick users into revealing sensitive information such as passwords, credit card numbers, or OTPs.
Cyber Bullying : The use of digital communication tools (social media, messaging apps, gaming platforms) to harass, threaten, embarrass, or intimidate a person. It includes spreading rumours, posting hurtful comments, or sharing private information without consent.
• Cybercrime : A hacker breaks into a company's database and steals credit card details of millions of customers.
• Cyber Law : Under the IT Act, Section 66C punishes identity theft with imprisonment up to three years and a fine.
• Hacking : An employee guesses a weak password and accesses confidential company files without permission. Alternatively, a security researcher (ethical hacker) is hired to find vulnerabilities.
• Phishing : You receive an email pretending to be from your bank with a link to "verify your account". The link leads to a fake website that steals your login credentials.
• Cyber Bullying : A group of students creates a fake social media profile of a classmate and posts embarrassing photos and messages, causing severe emotional distress.
Types of Cybercrime :
Types of Hackers :
Types of Phishing :
Forms of Cyber Bullying :
+------------------------------------------------+
| CYBERCRIME |
+--------+--------+--------+----------+---------+
| Hacking|Phishing|Bullying|ID Theft | Malware |
+--------+--------+--------+----------+---------+
| | |
v v v
+-------------------------------+
| CYBER LAWS |
| (IT Act, 2000 / IPC sections)|
+-------------------------------+
| Investigation → Prosecution |
+-------------------------------+
Cybercrime is a dark side of the digital revolution, and it affects everyone – from individual users to entire nations. Understanding common threats like hacking, phishing, and cyber bullying, along with the legal protections provided by cyber laws, is crucial for staying safe online. As technology evolves, so must our awareness, our laws, and our commitment to ethical digital behaviour. Cyber safety is a shared responsibility.
इंटरनेट हमारे जीवन का अभिन्न अंग बन गया है, लेकिन यह हमें विभिन्न डिजिटल खतरों से भी अवगत कराता है। अपराधी तकनीक का उपयोग करके व्यक्तिगत डेटा, धन और पहचान चुराते हैं। व्यक्ति, व्यवसाय और सरकारें अनधिकृत कंप्यूटर पहुँच, धोखाधड़ी वाले ईमेल और ऑनलाइन उत्पीड़न का सामना करती हैं। इंटरनेट की गुमनामी और वैश्विक पहुँच अपराधियों को पकड़ना और रोकना कठिन बना देती है। मुख्य समस्या है: कंप्यूटर और इंटरनेट के माध्यम से होने वाली आपराधिक गतिविधियों से व्यक्तियों और संगठनों की रक्षा कैसे की जाए, और ऐसे अपराधों को रोकने, पहचानने और दंडित करने के लिए कानूनी ढाँचे कैसे स्थापित किए जाएँ। इसी ने साइबर अपराध, साइबर सुरक्षा और साइबर कानूनों के क्षेत्र को जन्म दिया है।
साइबर अपराध (Cybercrime) : कोई भी अवैध गतिविधि जिसमें कंप्यूटर, नेटवर्क या डिजिटल डिवाइस शामिल हो। यह व्यक्तियों (पहचान चोरी, ऑनलाइन धोखाधड़ी), संपत्ति (हैकिंग, वायरस हमला) या सरकारों (साइबर आतंकवाद) को निशाना बना सकता है।
साइबर कानून (Cyber Laws) : इंटरनेट और डिजिटल संचार के उपयोग को नियंत्रित करने वाले कानूनी प्रावधान। ये परिभाषित करते हैं कि साइबर अपराध क्या है और दंड निर्धारित करते हैं। उदाहरण: भारत का सूचना प्रौद्योगिकी अधिनियम, 2000 (IT Act)।
हैकिंग (Hacking) : किसी कंप्यूटर सिस्टम या नेटवर्क में अनधिकृत प्रवेश। यह नैतिक (सुरक्षा जाँच के लिए अनुमति से) या अनैतिक/दुर्भावनापूर्ण (चोरी, क्षति या अवरोध के लिए) हो सकती है। ब्लैक‑हैट हैकर अपराधी होते हैं; व्हाइट‑हैट हैकर सुरक्षा मजबूत करते हैं।
फ़िशिंग (Phishing) : साइबर धोखाधड़ी का एक प्रकार जिसमें हमलावर भ्रामक ईमेल या संदेश भेजते हैं जो किसी विश्वसनीय स्रोत (जैसे बैंक या सोशल मीडिया साइट) से आते प्रतीत होते हैं, ताकि उपयोगकर्ता पासवर्ड, क्रेडिट कार्ड नंबर, OTP जैसी संवेदनशील जानकारी प्रकट कर दें।
साइबर बुलिंग (Cyber Bullying) : डिजिटल संचार उपकरणों (सोशल मीडिया, मैसेजिंग ऐप, गेमिंग प्लेटफ़ॉर्म) का उपयोग करके किसी व्यक्ति को परेशान करना, धमकाना, शर्मिंदा करना या डराना। इसमें अफ़वाहें फैलाना, आपत्तिजनक टिप्पणियाँ पोस्ट करना या बिना सहमति के निजी जानकारी साझा करना शामिल है।
• साइबर अपराध : एक हैकर किसी कंपनी के डेटाबेस में सेंध लगाकर लाखों ग्राहकों के क्रेडिट कार्ड विवरण चुरा लेता है।
• साइबर कानून : IT अधिनियम की धारा 66C पहचान चोरी को तीन साल तक की कैद और जुर्माने से दंडित करती है।
• हैकिंग : एक कर्मचारी कमज़ोर पासवर्ड का अनुमान लगाकर बिना अनुमति के गोपनीय कंपनी फ़ाइलें एक्सेस करता है। वैकल्पिक रूप से, एक सुरक्षा शोधकर्ता (नैतिक हैकर) को कमज़ोरियाँ खोजने के लिए काम पर रखा जाता है।
• फ़िशिंग : आपको अपने बैंक के नाम से एक ईमेल प्राप्त होता है जिसमें "अपना खाता सत्यापित करें" के लिए एक लिंक होता है। लिंक एक नकली वेबसाइट पर ले जाता है जो आपके लॉगिन क्रेडेंशियल चुरा लेती है।
• साइबर बुलिंग : छात्रों का एक समूह सहपाठी का फ़र्जी सोशल मीडिया प्रोफ़ाइल बनाकर शर्मनाक फ़ोटो और संदेश पोस्ट करता है, जिससे गंभीर भावनात्मक क्षति पहुँचती है।
साइबर अपराध के प्रकार :
हैकर्स के प्रकार :
फ़िशिंग के प्रकार :
साइबर बुलिंग के रूप :
+------------------------------------------------+
| साइबर अपराध |
+--------+--------+--------+----------+---------+
| हैकिंग | फ़िशिंग| बुलिंग | पहचान चोरी| मैलवेयर|
+--------+--------+--------+----------+---------+
| | |
v v v
+-------------------------------+
| साइबर कानून |
| (IT अधिनियम, 2000 / IPC धाराएँ)|
+-------------------------------+
| जाँच → अभियोजन |
+-------------------------------+
साइबर अपराध डिजिटल क्रांति का एक अंधकारमय पक्ष है, और यह सभी को प्रभावित करता है – व्यक्तिगत उपयोगकर्ताओं से लेकर संपूर्ण राष्ट्रों तक। हैकिंग, फ़िशिंग और साइबर बुलिंग जैसे सामान्य खतरों और साइबर कानूनों द्वारा प्रदत्त कानूनी संरक्षण को समझना ऑनलाइन सुरक्षित रहने के लिए महत्वपूर्ण है। जैसे‑जैसे तकनीक विकसित होती है, हमारी जागरूकता, हमारे कानून और नैतिक डिजिटल व्यवहार के प्रति हमारी प्रतिबद्धता भी बढ़नी चाहिए। साइबर सुरक्षा एक साझा ज़िम्मेदारी है।
With the rapid advancement of technology, electronic devices like computers, mobile phones, and televisions become obsolete very quickly. People discard old devices without thinking about where they end up. These discarded electronics, called e‑waste, are often handled unsafely – dumped in landfills, burned in open air, or processed by untrained workers who are exposed to harmful substances. The core problem is: how to manage the ever‑growing pile of electronic waste so that it does not poison our environment, harm human health, and waste valuable materials like gold, silver, and copper that can be recycled.
E‑waste (Electronic Waste) : Any discarded electrical or electronic equipment that is no longer useful or has reached the end of its life. This includes computers, laptops, printers, mobile phones, refrigerators, washing machines, batteries, and their components. E‑waste contains both valuable recyclable materials (gold, copper, aluminium) and hazardous substances (lead, mercury, cadmium, brominated flame retardants).
• An old CRT monitor contains about 2‑4 kg of lead. When dumped in a landfill, rain water can carry lead into the soil and groundwater.
• A mobile phone contains small amounts of gold, silver, and palladium in its circuit board. Recycling one million phones can recover about 34 kg of gold.
• In informal recycling yards, workers burn wires to extract copper, releasing toxic fumes that cause severe respiratory diseases.
• A school replaces 50 old computers. If given to a certified e‑waste recycler, the materials can be safely recovered and reused. If thrown in the dustbin, they become hazardous waste.
E‑waste is classified based on the type of equipment:
Consumer / Business
|
| (discarded electronics)
v
+-------------------+
| E‑waste Collection| (drop‑off centres, take‑back programs)
+-------------------+
|
v
+-------------------+
| Segregation & |
| Dismantling |
+-------------------+
|
v
+-------------------+
| Formal Recycler | -------> Recovery of metals, plastics, glass
+-------------------+
|
v
(Residual hazardous waste sent to special treatment / landfill)
E‑waste is both a challenge and an opportunity. If mismanaged, it poses severe environmental and health risks. If handled responsibly through formal recycling and circular economy principles, it becomes a rich source of valuable materials. As responsible citizens, we must reduce electronic waste by using devices longer, repairing instead of replacing, and always disposing of old electronics through authorised recyclers. Awareness and strict enforcement of e‑waste rules are the keys to a sustainable digital future.
प्रौद्योगिकी के तेज़ विकास के कारण कंप्यूटर, मोबाइल फ़ोन और टेलीविज़न जैसे इलेक्ट्रॉनिक उपकरण बहुत जल्दी पुराने हो जाते हैं। लोग बिना यह सोचे पुराने उपकरण फेंक देते हैं कि वे अंततः कहाँ जाएँगे। ये फेंके गए इलेक्ट्रॉनिक्स, जिन्हें ई‑कचरा कहते हैं, अक्सर असुरक्षित तरीके से संभाले जाते हैं – इन्हें कूड़े के ढेरों में फेंका जाता है, खुले में जलाया जाता है, या अप्रशिक्षित श्रमिकों द्वारा संसाधित किया जाता है जो हानिकारक पदार्थों के संपर्क में आते हैं। मुख्य समस्या है: इलेक्ट्रॉनिक कचरे के लगातार बढ़ते ढेर का प्रबंधन कैसे किया जाए ताकि यह हमारे पर्यावरण को ज़हरीला न करे, मानव स्वास्थ्य को नुकसान न पहुँचाए और सोना, चाँदी, ताँबा जैसे मूल्यवान पदार्थ बर्बाद न हों जिनका पुनर्चक्रण हो सकता है।
ई‑कचरा (E‑waste / Electronic Waste) : कोई भी फेंका गया इलेक्ट्रिकल या इलेक्ट्रॉनिक उपकरण जो अब उपयोगी नहीं है या अपने जीवनकाल के अंत तक पहुँच चुका है। इसमें कंप्यूटर, लैपटॉप, प्रिंटर, मोबाइल फ़ोन, फ्रिज, वाशिंग मशीन, बैटरियाँ और उनके कलपुर्जे शामिल हैं। ई‑कचरे में मूल्यवान पुनर्चक्रणीय पदार्थ (सोना, ताँबा, एल्युमिनियम) और खतरनाक पदार्थ (सीसा, पारा, कैडमियम, ब्रोमिनेटेड अग्निरोधी) दोनों होते हैं।
• एक पुराने CRT मॉनीटर में लगभग 2‑4 किलो सीसा (lead) होता है। जब इसे कूड़े के ढेर में फेंका जाता है, तो बारिश का पानी सीसे को मिट्टी और भूजल में ले जा सकता है।
• एक मोबाइल फ़ोन की सर्किट बोर्ड में थोड़ी मात्रा में सोना, चाँदी और पैलेडियम होता है। दस लाख फ़ोन का पुनर्चक्रण करने पर लगभग 34 किलो सोना प्राप्त किया जा सकता है।
• अनौपचारिक पुनर्चक्रण यार्ड में, मज़दूर ताँबा निकालने के लिए तारों को जलाते हैं, जिससे ज़हरीला धुआँ निकलता है जो गंभीर श्वसन रोगों का कारण बनता है।
• एक स्कूल 50 पुराने कंप्यूटर बदलता है। यदि उन्हें प्रमाणित ई‑कचरा पुनर्चक्रणकर्ता को दिया जाए, तो सामग्री सुरक्षित रूप से पुनः प्राप्त और पुनः उपयोग की जा सकती है। यदि कूड़ेदान में डाल दिया जाए, तो वे खतरनाक कचरा बन जाते हैं।
ई‑कचरे को उपकरण के प्रकार के आधार पर वर्गीकृत किया जाता है:
उपभोक्ता / व्यवसाय
|
| (फेंके गए इलेक्ट्रॉनिक्स)
v
+-------------------+
| ई‑कचरा संग्रहण | (ड्रॉप‑ऑफ़ सेंटर, वापसी कार्यक्रम)
+-------------------+
|
v
+-------------------+
| पृथक्करण और |
| निराकरण |
+-------------------+
|
v
+-------------------+
| औपचारिक पुनर्चक्रणकर्ता | -------> धातुओं, प्लास्टिक, काँच की पुनर्प्राप्ति
+-------------------+
|
v
(बचा हुआ खतरनाक कचरा विशेष उपचार / लैंडफिल में भेजा गया)
ई‑कचरा एक चुनौती भी है और एक अवसर भी। यदि कुप्रबंधित किया जाए तो यह गंभीर पर्यावरणीय और स्वास्थ्य जोखिम पैदा करता है। यदि औपचारिक पुनर्चक्रण और चक्रीय अर्थव्यवस्था सिद्धांतों के माध्यम से जिम्मेदारी से संभाला जाए तो यह मूल्यवान सामग्रियों का एक समृद्ध स्रोत बन जाता है। जिम्मेदार नागरिक के रूप में, हमें उपकरणों को अधिक समय तक उपयोग करके, बदलने के बजाय मरम्मत करवाकर, और हमेशा पुराने इलेक्ट्रॉनिक्स को अधिकृत पुनर्चक्रणकर्ताओं के माध्यम से निपटाकर इलेक्ट्रॉनिक कचरे को कम करना चाहिए। जागरूकता और ई‑कचरा नियमों का कड़ा प्रवर्तन सतत डिजिटल भविष्य की कुंजी है।
Technology has become an inseparable part of daily life — from smartphones and laptops to gaming consoles and earphones. However, prolonged and improper use of these devices leads to a range of health problems that often go unnoticed until they become severe. Many people work for hours in front of screens without breaks, sit with poor posture, listen to loud music through earphones, or stay up late scrolling social media. They do not realise that these habits cause eye strain, back pain, hearing loss, sleep disorders, and even mental health issues like anxiety and depression. The core problem is: how to educate users about the short‑term and long‑term health risks of technology overuse, so they can take preventive measures and adopt healthier digital habits.
Health Concerns Related to Technology Usage : The physical, mental, and social health problems that arise from excessive, improper, or unprotected use of digital devices, including computers, smartphones, headphones, and other gadgets. These concerns encompass a wide spectrum, from eye strain (Computer Vision Syndrome) and musculoskeletal disorders (Repetitive Strain Injury, Text Neck) to hearing damage, sleep disruption, technology addiction, and psychological issues such as anxiety, depression, and social isolation.
• Computer Vision Syndrome (CVS) : A student studies for online classes 6‑8 hours a day without an anti‑glare screen or proper lighting. After a few weeks, she experiences dry eyes, headaches, and blurred vision — all symptoms of CVS.
• Text Neck : A teenager constantly tilts his head forward to look at his phone. Over months, this causes chronic neck pain and strain on the cervical spine, known as "text neck".
• Hearing Loss : A young adult listens to music at maximum volume through earphones daily. Over time, the constant loud sound damages the sensitive hair cells in the inner ear, leading to permanent hearing loss or tinnitus (ringing in the ears).
• Sleep Deprivation : A working professional uses his phone in bed late at night. The blue light from the screen suppresses melatonin, making it difficult to fall asleep, resulting in poor sleep quality and daytime fatigue.
• Technology Addiction : A child spends every free moment playing online games, neglecting studies, outdoor play, and family interaction. This compulsive behaviour is a sign of digital addiction, causing irritability when devices are taken away.
Health problems from technology can be grouped into three main categories:
+------------------------------------------------------+
| EXCESSIVE / IMPROPER TECHNOLOGY USE |
+------------------------------------------------------+
| | |
v v v
+-------------+ +--------------+ +--------------+
| PHYSICAL | | MENTAL | | SOCIAL |
| HEALTH | | HEALTH | | HEALTH |
+------+------+ +------+-------+ +------+-------+
| Eyes | Posture| | Addiction | | Isolation |
| Ears | Body | | Anxiety | | Conflicts |
+------+--------+ | Sleep loss | | Lost skills|
+-------------+ +------------+
Technology overuse impacts all three dimensions of health — physical, mental, and social — often interlinked.
Technology is a powerful tool, but like any tool, it must be used wisely. The health concerns associated with technology — from eye strain and back pain to digital addiction and sleep disorders — are real, widespread, and preventable. Awareness is the first step towards protection. By understanding the risks, practising good ergonomics, limiting screen time, taking breaks, and maintaining a balanced lifestyle, we can enjoy the benefits of technology without compromising our health. Schools, families, and workplaces must actively promote healthy technology habits.
प्रौद्योगिकी दैनिक जीवन का अभिन्न अंग बन गई है — स्मार्टफ़ोन, लैपटॉप से लेकर गेमिंग कंसोल और इयरफ़ोन तक। लेकिन इन उपकरणों का लंबे समय तक और गलत तरीके से उपयोग कई स्वास्थ्य समस्याओं को जन्म देता है, जो गंभीर होने तक अक्सर अनदेखी रहती हैं। बहुत से लोग बिना ब्रेक लिए घंटों स्क्रीन के सामने काम करते हैं, गलत मुद्रा में बैठते हैं, इयरफ़ोन पर तेज़ आवाज़ में संगीत सुनते हैं, या देर रात तक फ़ोन चलाते हैं। उन्हें एहसास नहीं होता कि ये आदतें आँखों में तनाव, पीठ दर्द, सुनने की क्षमता में कमी, नींद विकार और चिंता व अवसाद जैसी मानसिक समस्याओं का कारण बनती हैं। मुख्य समस्या है: उपयोगकर्ताओं को प्रौद्योगिकी के अति उपयोग के अल्पकालिक और दीर्घकालिक स्वास्थ्य जोखिमों के बारे में कैसे शिक्षित किया जाए, ताकि वे निवारक उपाय अपनाएँ और स्वस्थ डिजिटल आदतें विकसित करें।
प्रौद्योगिकी उपयोग से संबंधित स्वास्थ्य चिंताएँ : कंप्यूटर, स्मार्टफ़ोन, हेडफ़ोन और अन्य गैजेट्स के अत्यधिक, अनुचित या असुरक्षित उपयोग से उत्पन्न शारीरिक, मानसिक और सामाजिक स्वास्थ्य समस्याएँ। इनमें आँखों का तनाव (कंप्यूटर विज़न सिंड्रोम), मस्कुलोस्केलेटल विकार (रिपीटिटिव स्ट्रेन इंजरी, टेक्स्ट नेक), श्रवण हानि, नींद में बाधा, प्रौद्योगिकी की लत और चिंता, अवसाद व सामाजिक अलगाव जैसी मनोवैज्ञानिक समस्याएँ शामिल हैं।
• कंप्यूटर विज़न सिंड्रोम (CVS) : एक छात्रा बिना एंटी‑ग्लेयर स्क्रीन या उचित प्रकाश के ऑनलाइन कक्षाओं के लिए प्रतिदिन 6‑8 घंटे पढ़ती है। कुछ सप्ताह बाद उसे सूखी आँखें, सिरदर्द और धुँधली दृष्टि का अनुभव होता है — ये सब CVS के लक्षण हैं।
• टेक्स्ट नेक : एक किशोर लगातार अपने फ़ोन को देखने के लिए सिर आगे झुकाए रखता है। महीनों में, इससे गर्दन में पुराना दर्द और सर्वाइकल स्पाइन पर दबाव पड़ता है, जिसे "टेक्स्ट नेक" कहते हैं।
• श्रवण हानि : एक युवा प्रतिदिन इयरफ़ोन पर अधिकतम ध्वनि में संगीत सुनता है। समय के साथ, लगातार तेज़ आवाज़ आंतरिक कान की संवेदनशील बाल कोशिकाओं को क्षति पहुँचाती है, जिससे स्थायी श्रवण हानि या कानों में घंटी बजने (टिनिटस) की समस्या हो सकती है।
• नींद की कमी : एक कामकाजी पेशेवर देर रात बिस्तर पर फ़ोन चलाता है। स्क्रीन की नीली रोशनी मेलाटोनिन को दबा देती है, जिससे सोना मुश्किल हो जाता है, नींद की गुणवत्ता खराब होती है और दिन में थकान बनी रहती है।
• प्रौद्योगिकी की लत : एक बच्चा हर खाली पल ऑनलाइन गेम खेलने में बिताता है, पढ़ाई, बाहरी खेल और परिवार से दूर होता जाता है। यह अनिवार्य व्यवहार डिजिटल लत का संकेत है, जिससे उपकरण छीनने पर चिड़चिड़ापन होता है।
प्रौद्योगिकी से होने वाली स्वास्थ्य समस्याओं को तीन मुख्य श्रेणियों में बाँटा जा सकता है:
+------------------------------------------------------+
| अत्यधिक/अनुचित प्रौद्योगिकी उपयोग |
+------------------------------------------------------+
| | |
v v v
+-------------+ +--------------+ +--------------+
| शारीरिक | | मानसिक | | सामाजिक |
| स्वास्थ्य | | स्वास्थ्य | | स्वास्थ्य |
+------+------+ +------+-------+ +------+-------+
| आँखें| मुद्रा| | लत | | अलगाव |
| कान | शरीर | | चिंता | | कलह |
+------+--------+ | नींद की कमी| | कौशल हानि |
+-------------+ +------------+
प्रौद्योगिकी का अति उपयोग स्वास्थ्य के तीनों आयामों — शारीरिक, मानसिक और सामाजिक — को प्रभावित करता है, जो अक्सर आपस में जुड़े होते हैं।
प्रौद्योगिकी एक शक्तिशाली उपकरण है, लेकिन किसी भी उपकरण की तरह, इसका बुद्धिमानी से उपयोग होना चाहिए। प्रौद्योगिकी से जुड़ी स्वास्थ्य चिंताएँ — आँखों के तनाव और पीठ दर्द से लेकर डिजिटल लत और नींद विकार तक — वास्तविक, व्यापक और रोकी जा सकने वाली हैं। जागरूकता सुरक्षा की ओर पहला कदम है। जोखिमों को समझकर, अच्छी एर्गोनोमिक्स का अभ्यास करके, स्क्रीन टाइम सीमित करके, ब्रेक लेकर और संतुलित जीवनशैली बनाए रखकर हम अपने स्वास्थ्य से समझौता किए बिना प्रौद्योगिकी के लाभ उठा सकते हैं। स्कूलों, परिवारों और कार्यस्थलों को सक्रिय रूप से स्वस्थ प्रौद्योगिकी आदतों को बढ़ावा देना चाहिए।