lecture 2 | project 1 | pandas dataframe to excel report using xlsx writer |

Опубликовано: 26 Май 2026
на канале: DEwithDhairy
308
9

Welcome to our tutorial on advanced DataFrame formatting with pandas! In this video, we will walk you through how to use pd.ExcelWriter along with the xlsxwriter engine to enhance the appearance of your Excel reports.

📌 What You’ll Learn:

Introduction to pd.ExcelWriter: Understand the basics of pd.ExcelWriter and why it's useful.
Setting up XlsxWriter: Learn how to integrate xlsxwriter as the engine for pd.ExcelWriter.
Formatting DataFrames: Discover how to apply various formatting options such as fonts, colors, and conditional formatting to your DataFrame.
Customizing Excel Sheets: Tips on adding headers, and adjusting column widths for a professional look.
Saving and Exporting: How to save your beautifully formatted DataFrame to an Excel file.

Formatting properties U will learn In this video:
workbook
worksheet
set_column()
add_format()
money format
percent format
indexing in excel

Tools & Libraries Used:

Python
Pandas
XlsxWriter


============================================================
Create DataFrame :
=================

Store Data
data = {
'SSN': ['HDJ-45-6789', 'JDKS-65-4321', 'JJS-55-5555', 'JKX-22-3333', 'EDW-33-2222',
'WWWQ-22-1111', 'WDW-11-4444', 'ECC-77-8888', 'EDQWD-66-5555', 'DWDQ-99-6666',
'DQWD-88-7777', 'DWQD-11-2222', 'DDD-44-5555', 'DQDD-55-6666', 'WDQ-66-7777'],
'Product Name': ['Laptop', 'Smartphone', 'Tablet', 'Monitor', 'Keyboard',
'Mouse', 'Printer', 'Scanner', 'Webcam', 'Headphones',
'Speakers', 'Router', 'Modem', 'Smartwatch', 'Charger'],
'Dispatch Date': pd.date_range(start='2023-01-15', periods=15, freq='M'),
'Country': ['USA', 'Canada', 'USA', 'Canada', 'USA',
'Canada', 'USA', 'Canada', 'USA', 'Canada',
'USA', 'Canada', 'USA', 'Canada', 'USA'],
'State': ['California', 'Ontario', 'Texas', 'Quebec', 'Florida',
'British Columbia', 'New York', 'Alberta', 'Illinois', 'Manitoba',
'Pennsylvania', 'Nova Scotia', 'Ohio', 'New Brunswick', 'Georgia'],
'Month Revenue': [1000, 1200, 1100, 1300, 1250,
1400, 1350, 1500, 1450, 1600,
1550, 1700, 1650, 1800, 1750]
}

Creating DataFrame using above data
df = pd.DataFrame(data)

Calculate percentage change in revenue
df['Percentage Change'] = df['Month Revenue'].pct_change().fillna(0)

df


Need Help ? Connect With me 1:1 - https://topmate.io/dewithdhairy

Let's connect on LinkedIn :   / dhirajgupta141  


pyspark 30 days challenge :    • pyspark 30 days challenge  

top interview question and answer in pyspark :
   • top interview questions and answers in pys...  

PySpark Installation and Setup :    • Spark Installation | PySpark Installation ...  

DSA In Python Interview Series :    • dsa for data engineer | dsa for data analy...  

PySpark Interview Series :    • pyspark interview questions and answers  

Pandas Interview Series :    • pandas interview questions and answers  

SQL Interview Series :    • sql interview questions and answers  

#sql #pyspark #youtube #dataengineers #coding #interview #faang #pandas #excel #xlsx #xlsxwriter #reports #dataanalytics