Data Science · मराठी आवृत्ती
22.2 to_csv आणि to_excel — Blinkit summaries
या course चे सर्व chapters (py + ch)
- How to Use This Free Data Science Course
- How to Install Python, Jupyter Notebook and VS Code for Data Science (Windows and Mac)
- Python Variables and Data Types Explained for Beginners (int, float, str, bool)
- Python Strings Tutorial: Slicing, f-strings and String Methods with Examples
- Python Lists, Tuples, Dictionaries and Sets Explained with Examples
- Python if, elif and else Statements with Real Examples for Beginners
- Python for Loops and while Loops Explained with Examples (range, break, continue)
- Python Functions Tutorial: def, return, Arguments and lambda with Examples
- Python Errors and Exceptions: How to Use try, except, else and finally
- How to Read and Write CSV, JSON and Text Files in Python (with open and with)
- Python Modules, pip and Virtual Environments (venv) Explained for Beginners
- Python Classes and Objects for Beginners: OOP Basics with Simple Examples
- NumPy Tutorial for Beginners: Arrays, Maths and Filtering in Python
- Python Mini Projects for Beginners: 5 Practice Projects Before Learning pandas
- Data Science vs Data Analytics Tutorial
- Python Jupyter Setup for Data Science
- Python Basics for Data Science Tutorial
- NumPy Essentials for Data Science Tutorial
- pandas DataFrames and Series Tutorial
- Filter and Sort Data in pandas Tutorial
- pandas GroupBy and Aggregations Tutorial
- Merge and Concat Data in pandas Tutorial
- Data Cleaning in pandas A–Z Tutorial
- Dates and Text in pandas – Free Tutorial
- Reshape Data: melt and pivot_table
- Exploratory Data Analysis in Python
- matplotlib Visualization Tutorial – Free
- seaborn Visualization Tutorial – Free
- Chart Choice and Data Storytelling
- Data Science Project: Blinkit Maharashtra
- Data Science Practice Exercises
- Data Science Interview Questions
- pandas matplotlib seaborn Cheat Sheet
- Data Science Glossary – Free Tutorial
- Stats for Data Work Mean Median IQR
- Export CSV Excel PNG from pandas Tutorial
- Common pandas Mistakes and Fixes Tutorial
- Load SQL Query Results into pandas DataFrame – Free Tutorial
- How to Rank and Running Totals in pandas
- How to Read APIs, JSON and Zipped CSVs into pandas
- How to Use Git with Jupyter Notebooks for Data Projects
- How to Merge and Join Tables in pandas for Blinkit Data
- What Is Machine Learning Simple Explanation
- Machine Learning Workflow Step by Step
- Train Test Split in Machine Learning sklearn
- Features and Labels in Machine Learning
- Linear Regression in Python with sklearn
- Classification with Logistic Regression in Python
- Decision Trees and Random Forests in Python
- K-Means Clustering in Python for Beginners
- How to Check If Your ML Model Is Good
- Overfitting and Underfitting in Machine Learning
- End-to-End ML Project India Dataset
- Data Preprocessing for ML: Impute Scale Encode
- What Is a Neural Network Simple Explanation
- Activation Loss Gradient Descent Plain English
- Backpropagation Intuition No Heavy Maths
- Install PyTorch and First Tensors
- Your First Neural Network in PyTorch
- Deep Learning vs Classical ML When to Use Which
- Convolutional Neural Networks CNNs for Images
- Small CNN Image Project in PyTorch
- What Transformers Are Text and Sequences
- Tiny Text Classifier Transformer Intro PyTorch
- What Is Natural Language Processing NLP
- Text Cleaning and TF-IDF in Python sklearn
- Sentiment Analysis Project in Python TF-IDF
- NLP vs ChatGPT Classical NLP and Generative AI
हे का शिकायचं?
Summary table तयार झाली की ती file मध्ये उतरवा — copy-paste करू नका.
हे काय आहे?
df.to_csv(...) आणि df.to_excel(...). Encoding आणि index=False लक्षात ठेवा.
कसं करायचं?
Step 1. Summary DataFrame तयार करा.
Step 2. to_csv(index=False) चालवा.
Step 3. to_excel ने sheet_name द्या.
Step 4. File उघडून rows तपासा.
उदाहरणं: copy करा आणि चालवा
उदाहरण A — Build and export (fictional).
import pandas as pd
from pathlib import Path
Path("outputs").mkdir(exist_ok=True)
df = pd.DataFrame({
"order_id": [
"BLK-261022-001", "BLK-261022-002", "BLK-261022-003",
"AMN-261022-004", "BLK-261022-005", "BLK-261022-006",
"BLK-261022-007", "AMN-261022-008", "BLK-261022-009",
],
"city": [
"Pune", "Pune", "Solapur", "Nashik", "Kolhapur",
"Nagpur", "Sambhaji Nagar", "Pune", "Nashik",
],
"status": [
"Delivered", "Cancelled", "Delivered", "Delivered", "Delivered",
"Returned", "Delivered", "Delivered", "Delivered",
],
"amount": [189, 90, 120, 95, 210, 150, 340, 72, 88],
"customer": [
"Ruhi Bagale", "Amir", "Zoya", "Salman", "Ravina",
"Raja", "Rani", "Shraddha Bagale", "Shahrukh",
],
})
summary = (
df.groupby(["city", "status"], as_index=False)
.agg(orders=("order_id", "count"), gmv_inr=("amount", "sum"))
.sort_values(["gmv_inr", "city"], ascending=[False, True])
)
summary.to_csv("outputs/city_status.csv", index=False)
summary.to_excel("outputs/city_status.xlsx", index=False, sheet_name="city_status")
print(summary)
print("delivered gmv check", df.loc[df["status"].eq("Delivered"), "amount"].sum())
What you should see. A tidy sheet: one row per city×status, columns orders and gmv_inr. Pune Delivered should not include the Cancelled ₹90.
उदाहरण B — Multi-sheet workbook for Ravindra.
daily = (
df.assign(day="22-10-2026")
.groupby(["day", "city"], as_index=False)
.agg(orders=("order_id", "count"), gmv_inr=("amount", "sum"))
)
notes = pd.DataFrame({
"note": [
"Fictional sample for learning only.",
"GMV = sum of amount; confirm status filter with ops.",
"Contact for questions: analyst@example.com",
]
})
with pd.ExcelWriter("outputs/blinkit_friday_pack.xlsx", engine="openpyxl") as xlw:
summary.to_excel(xlw, sheet_name="city_status", index=False)
daily.to_excel(xlw, sheet_name="daily_city", index=False)
notes.to_excel(xlw, sheet_name="notes", index=False)
उदाहरण C — CSV for systems; Excel for people.
# UTF-8 CSV for pipelines / pandas peers
summary.to_csv("outputs/city_status_utf8.csv", index=False, encoding="utf-8")
# Excel-friendly CSV on some Windows setups (only if a peer asks)
summary.to_csv("outputs/city_status_utf8_sig.csv", index=False, encoding="utf-8-sig")
Prefer utf-8 by default. Use utf-8-sig when a colleague’s Excel mangles Marathi city notes (if you ever add them).