Creating customizable Excel reports using XlsxWriter
While creating an Excel file from a Pandas DataFrame is super easy, you cannot easily customize it. In this recipe, you will learn how to use the XlsxWriter
Python library to create a highly customizable report in Excel.
How to do it…
- First, import the Python libraries that you need:
from pymongo import MongoClient import pandas as pd from time import strftime
- Next, create a connection to MongoDB, and specify the accidents collection:
client = MongoClient('localhost', 27017) db = client.pythonbicookbook collection = db.accidents
- Once you have created the connection, run a query to retrieve the first
1000
records in which an accident happened on a Friday:data = collection.find({"Day_of_Week": 6}).limit(1000) ...
Get Python Business Intelligence Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.