⏱️2 min read · 313 words

पांडा2026 में डेटा विश्लेषण के लिए सबसे अधिक उपयोग की जाने वाली पायथन लाइब्रेरी है। चाहे आप सीएसवी की सफाई कर रहे हों, बिक्री डेटा एकत्र कर रहे हों, या मशीन लर्निंग के लिए डेटासेट तैयार कर रहे हों, पांडा एक उपकरण है। यह ट्यूटोरियल प्रत्येक डेटा पेशेवर के लिए आवश्यक आवश्यक परिचालनों को शामिल करता है।
📋 Table of Contents
स्थापित करें और आयात करें
pip install pandas numpy
import pandas as pd
import numpy as np
print(pd.__version__) # 2.2+
डेटाफ़्रेम बनाना
# From dict
df = pd.DataFrame({
'name': ['Alice', 'Bob', 'Carol', 'Dave'],
'age': [25, 30, 35, 28],
'salary': [70000, 85000, 92000, 78000],
'dept': ['Eng', 'Mktg', 'Eng', 'HR'],
})
# From CSV
df = pd.read_csv('data.csv')
# From JSON
df = pd.read_json('data.json')
print(df.head()) # First 5 rows
print(df.info()) # Column types and nulls
print(df.describe()) # Stats summary
डेटा का चयन
# Select column
df['name'] # Series
df[['name', 'salary']] # DataFrame
# Select rows by condition
df[df['salary'] > 80000]
df[(df['dept'] == 'Eng') & (df['age'] < 35)]
# iloc — by position
df.iloc[0] # First row
df.iloc[1:3] # Rows 1-2
# loc — by label
df.loc[df['dept'] == 'Eng', ['name', 'salary']]
सफ़ाई डेटा
# Check nulls
df.isnull().sum()
# Drop rows with any null
df.dropna(inplace=True)
# Fill nulls
df['salary'].fillna(df['salary'].mean(), inplace=True)
# Remove duplicates
df.drop_duplicates(inplace=True)
# Rename columns
df.rename(columns={'name': 'full_name'}, inplace=True)
# Change dtype
df['age'] = df['age'].astype(int)
समूहीकरण और एकत्रीकरण
# Group by department, get stats
summary = df.groupby('dept').agg(
count=('name', 'count'),
avg_salary=('salary', 'mean'),
max_salary=('salary', 'max'),
).reset_index()
print(summary)
# dept count avg_salary max_salary
# Eng 2 81000.0 92000
# HR 1 78000.0 78000
# Mktg 1 85000.0 85000
डेटाफ़्रेम को मर्ज करना
# Two DataFrames
employees = pd.DataFrame({'emp_id': [1,2,3], 'name': ['Alice','Bob','Carol']})
salaries = pd.DataFrame({'emp_id': [1,2,4], 'salary': [70000,85000,60000]})
# Inner join (only matching)
merged = employees.merge(salaries, on='emp_id', how='inner')
# Left join (keep all employees)
merged = employees.merge(salaries, on='emp_id', how='left')
कार्य लागू करना
# Apply function to column
df['salary_band'] = df['salary'].apply(
lambda s: 'High' if s > 90000 else ('Mid' if s > 75000 else 'Low')
)
# Apply to multiple columns
df[['age','salary']].apply(lambda col: col / col.max())
# Vectorized operations (faster than apply)
df['salary_k'] = df['salary'] / 1000
df['senior'] = df['age'] >= 30
निर्यात परिणाम
df.to_csv('output.csv', index=False)
df.to_excel('output.xlsx', index=False)
df.to_json('output.json', orient='records')
निष्कर्ष
पांडा वास्तविक दुनिया के 95% डेटा से संबंधित कार्यों को संभालते हैं। मास्टरgroupby,merge, और वेक्टरकृत संचालन और आप सेकंडों में लाखों पंक्तियों को संसाधित करेंगे। विज़ुअलाइज़ेशन के लिए मैटप्लोटलिब या प्लॉटली के साथ संयोजन करें, या एमएल के लिए स्किकिट-लर्न के लिए साफ़ किए गए डेटा को सौंप दें।
🔗 Share this article
✍️ Leave a Comment