Data Handling in Python - Complete Hindi Guide for AI

Working with datasets easily

📂 Data Handling in Python - Data को Manage करना सीखें (हिंदी में)

Python की मदद से Data को पढ़ना, लिखना, साफ़ करना और transform करना सीखिए, खासकर AI और Machine Learning के लिए।

🔰 Python में Data Handling क्यों जरूरी है?

AI और Machine Learning में 70% समय data को सही करने, साफ़ करने और analyze करने में लगता है। Python में Pandas जैसी libraries इस काम को बहुत आसान बना देती हैं।

📄 1. CSV Files Read & Write करना

import pandas as pd
df = pd.read_csv("data.csv")
print(df.head())
df.to_csv("new_data.csv", index=False)
  • CSV Files को पढ़ना और लिखना
  • Index को ignore करना

📊 2. Excel Files के साथ काम करना

df = pd.read_excel("data.xlsx")
df.to_excel("output.xlsx")
  • read_excel() और to_excel() functions
  • Multiple Sheets support

🧾 3. JSON और Dictionaries

import json

# Dictionary to JSON
data = {"name": "Rahul", "age": 21}
with open("data.json", "w") as f:
    json.dump(data, f)

# JSON to Dictionary
with open("data.json") as f:
    loaded = json.load(f)
    print(loaded)

🧹 4. Data Cleaning (Missing Values & Duplicates)

# Missing values check
print(df.isnull().sum())

# Fill missing values
df.fillna(0, inplace=True)

# Drop duplicates
df.drop_duplicates(inplace=True)
  • isnull(), fillna(), dropna()
  • drop_duplicates()

🔁 5. Data Transformation & Filtering

# Column create
df["total"] = df["math"] + df["science"]

# Filter rows
filtered = df[df["math"] > 50]
  • नई columns जोड़ना
  • Rows को filter करना (conditions)

📌 6. Grouping और Aggregation

# Grouping by class
grouped = df.groupby("class")["marks"].mean()
print(grouped)
  • groupby()
  • mean(), sum(), count() functions

✅ निष्कर्ष

Data Handling Python में एक core skill है। यह आपको किसी भी raw dataset को AI/ML model-ready बनाने में मदद करता है। Pandas और JSON tools से Data Manipulation बहुत आसान हो जाता है।

🚀 अगले ब्लॉग में: Python Visualization Tools (Hindi में)