{"id":252706,"date":"2026-07-13T02:17:56","date_gmt":"2026-07-12T23:17:56","guid":{"rendered":"https:\/\/1kitap1.com\/en\/automate-excel-with-python-john-wengler\/"},"modified":"2026-07-13T02:17:56","modified_gmt":"2026-07-12T23:17:56","slug":"automate-excel-with-python-john-wengler","status":"publish","type":"post","link":"https:\/\/1kitap1.com\/en\/automate-excel-with-python-john-wengler\/","title":{"rendered":"Automate Excel With Python &#8211; John Wengler"},"content":{"rendered":"<figure style=\"text-align:center;margin:0 auto 1.5em;\"><img decoding=\"async\" src=\"https:\/\/1kitap1.com\/en\/wp-content\/uploads\/2026\/07\/f7556cb0b285ebf7.jpg\" alt=\" - Unknown book cover\" style=\"max-width:300px;width:100%;height:auto;box-shadow:0 4px 12px rgba(0,0,0,.25);border-radius:4px;\"\/><\/figure>\n<p>If you lean toward greater efficiency and more tightly packed code, that\u2019s perfectly fine. Listing 7-7 demonstrates the &#8216;max&#8217; and &#8216;min&#8217; arguments for aggfunc, which correspond to Excel\u2019s MAX and MIN functions. >>> dfMax = pd.crosstab( &#8230; index = dfPets[&#8216;Type&#8217;], &#8230; columns = dfPets[&#8216;City&#8217;], &#8230; aggfunc = &#8216;max&#8217;, &#8230; values = dfPets[&#8216;Weight&#8217;]) >>> print(dfMax) City Boston Chicago Type Cat 11.0 NaN Dog 10.0 8.0 Frog NaN 6.0 >>> dfMin = pd.crosstab( &#8230; index = dfPets[&#8216;Type&#8217;], &#8230; columns = dfPets[&#8216;City&#8217;], &#8230; aggfunc = &#8216;min&#8217;, &#8230; values = dfPets[&#8216;Weight&#8217;]) >>> print(dfMin) City Boston Chicago Type Cat 9.0 NaN Dog 10.0 7.0 Frog NaN 6.0 Listing 7-7: Finding maximum and minimum values with the aggfunc arguments &#8216;max&#8217; and &#8216;min&#8217; Likewise, the &#8216;mean&#8217; and &#8216;median&#8217; arguments replicate the Excel formulas AVERAGE and MEDIAN, as Listing 7-8 demonstrates.<\/p>\n<p>>>> dfMean = pd.crosstab( &#8230; index = dfPets[&#8216;Type&#8217;], &#8230; columns = dfPets[&#8216;City&#8217;], &#8230; aggfunc = &#8216;mean&#8217;, &#8230; values = dfPets[&#8216;Weight&#8217;]) >>> print(dfMean) City Boston Chicago Type Cat 10.0 NaN Dog 10.0 7.5 Frog NaN 6.0 >>> dfMedian = pd.crosstab( &#8230; index = dfPets[&#8216;Type&#8217;], &#8230; columns = dfPets[&#8216;City&#8217;], &#8230; aggfunc = &#8216;median&#8217;, &#8230; values = dfPets[&#8216;Weight&#8217;]) >>> print(dfMedian) City Boston Chicago Type Cat 10.0 NaN Dog 10.0 7.5 Frog NaN 6.0 Listing 7-8: Calculating statistics with the &#8216;mean&#8217; and &#8216;median&#8217; aggfunc arguments Listings 7-6 through 7-8 are just a few common examples of how changing the aggfunc parameter\u2019s values can generate different cross- tabulations.<\/p>\n<p>I hope they inspire you to search other resources for more applications. Using Multiple Aggregate Functions Spreadsheets simplify tasks such as creating a multimetric table like the one shown in Figure 7-3, where Table B summarizes a count and a summation side by side from the source data in Table A. Figure 7-3: A simple Excel example that converts source data into a multimetric table In Excel, you need separate formulas for each metric\u2014COUNTIF for frequency counts and SUMIF for totals\u2014as shown in Figure 7-3.<\/p>\n<p>Each column requires its own formula to generate the complete summary shown in Figure 7-4.<\/p>\n<blockquote>\n<p>AUTOMATE EXCEL WITH PYTHON. Copyright \u00a9 2026 by John Wengler. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.<\/p>\n<p>First printing 30 29 28 27 26 1 2 3 4 5 ISBN-13: 978-1-7185-0464-6 (print) ISBN-13: 978-1-7185-0465-3 (ebook) Published by No Starch Press\u00ae, Inc. 245 8th Street, San Francisco, CA 94103 phone: +1.415.863.9900 www.nostarch.com; info@nostarch.com Publisher: William Pollock Managing Editor: Jill Franklin Production Manager: Sabrina Plomitallo-Gonz\u00e1lez Production Editor: Jennifer Kepler Developmental Editor: Rachel Monaghan Cover Illustrator: Rob Fiore Interior Design: Octopod Studios Technical Reviewer: Daniel Zingaro Copyeditor: Ryan E.<\/p>\n<p>Holman Proofreader: Michael Fedison Indexer: BIM Creatives, LLC Library of Congress Control Number: 2026001077 For customer service inquiries, please contact info@nostarch.com. For information on distribution, bulk sales, corporate sales, or translations: sales@nostarch.com. For permission to translate this work: rights@nostarch.com. To report counterfeit copies or piracy: counterfeit@nostarch.com. The authorized representative in the EU for product safety and compliance is EU Compliance Partner, P\u00e4rnu mnt. 139b-14, 11317 Tallinn, Estonia, hello@eucompliancepartner.com, +3375690241. No Starch Press and the No Starch Press iron logo are registered trademarks of No Starch Press, Inc.<\/p>\n<p>Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The information in this book is distributed on an \u201cAs Is\u201d basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc.<\/p>\n<p>shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it. 1kitap1.com\/en For Dragana, naturally. 1kitap1.com\/en About the Author John Wengler enjoys a Mark Twain\u2013like career spanning journalism, community planning, risk management, and compliance.<\/p>\n<p>He taught himself Python to upgrade a spreadsheet process to help an employer save millions on a third-party system. John wrote the 2001 book Managing Energy Risk, as well as dozens of industry articles on corporate governance. A distinguished public speaker, he has taught courses at the Illinois Institute of Technology and Tulane University.<\/p>\n<\/blockquote>\n<p><em>This is a short excerpt from the opening of &ldquo;&rdquo; by Unknown, quoted for review and introduction purposes. All rights belong to the copyright holders.<\/em><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/1kitap1.com\/en\/automate-excel-with-python-john-wengler\/#Book_Information\" >Book Information<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/1kitap1.com\/en\/automate-excel-with-python-john-wengler\/#Reading_Word_Statistics\" >Reading &amp; Word Statistics<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/1kitap1.com\/en\/automate-excel-with-python-john-wengler\/#Most_Frequent_Words\" >Most Frequent Words<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/1kitap1.com\/en\/automate-excel-with-python-john-wengler\/#PDF_Download\" >PDF Download<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Book_Information\"><\/span>Book Information<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Unique ID:<\/strong> f7556cb0b285ebf7<\/li>\n<li><strong>File Extension:<\/strong> .pdf<\/li>\n<li><strong>File Size:<\/strong> 12,880,422 bytes (12.284 MB)<\/li>\n<li><strong>Title:<\/strong> &#8211;<\/li>\n<li><strong>Author:<\/strong> Unknown<\/li>\n<li><strong>ISBN:<\/strong> 9781718504646, 9781718504653<\/li>\n<li><strong>Pages:<\/strong> 511<\/li>\n<li><strong>Language:<\/strong> English (en)<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Reading_Word_Statistics\"><\/span>Reading &amp; Word Statistics<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Estimated Reading Time:<\/strong> 484.82 minutes<\/li>\n<li><strong>Total Words:<\/strong> 96,965<\/li>\n<li><strong>Total Characters:<\/strong> 638,984<\/li>\n<li><strong>Average Words per Page:<\/strong> 189.76<\/li>\n<li><strong>Average Characters per Page:<\/strong> 1250.46<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Most_Frequent_Words\"><\/span>Most Frequent Words<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>dataframe (831), print (784), type (728), excel (699), column (694), dog (688), name (640), python (555), dfpets (550), method (546), list (535), index (505), values (459), listing (408), data (407), file (406), columns (405), dataframes (390), new (383), cat (374), pandas (359), object (339), value (329), use (316), using (309), first (294), datetime (294), import (288), bounce (280), function (276), ronnie (259), objects (248), holly (241), date (233), like (226), obj (226), one (222), example (222), string (217), chapter (214), folder (197), labels (196), workbook (188), pathname (188), sheet (185), default (183), dict (181), row (179), parameter (177), code (176), book (172), nan (172), you\u2019ll (165), weight (164), source (161), merge (159), single (155), set (155), also (151), age (151), formatting (149), rows (148), variable (148), shown (147), str (147), table (143), left (141), module (139), city (138), cell (137), email (137), right (136), figure (136), two (135), xlsx (134), creating (131), strings (128), different (122), returns (120), create (119), series (118), read (117), today (117), script (116), count (115), time (114), label (113), want (111), chicago (110), true (109), pets (109), working (108), lists (107), display (106), crosstab (106), types (105), you\u2019re (105), enter (105), attribute (104), files (103).<\/p>\n<h2><span class=\"ez-toc-section\" id=\"PDF_Download\"><\/span>PDF Download<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align:center;\"><a href=\"https:\/\/1kitap1.com\/en\/wp-content\/uploads\/2026\/07\/automate-excel-with-python-john-wengler.pdf\" download rel=\"nofollow\" style=\"display:inline-block;background:#2271b1;color:#ffffff;padding:14px 36px;border-radius:6px;text-decoration:none;font-weight:bold;font-size:1.05em;\">&#11015;&#65039; PDF Download<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you lean toward greater efficiency and more tightly packed code, that\u2019s perfectly fine. Listing 7-7 demonstrates the &#8216;max&#8217; and &#8216;min&#8217; arguments for aggfunc, which correspond to Excel\u2019s MAX and MIN functions. >>> dfMax = pd.crosstab( &#8230; index = dfPets[&#8216;Type&#8217;], &#8230; columns = dfPets[&#8216;City&#8217;], &#8230; aggfunc = &#8216;max&#8217;, &#8230; values = dfPets[&#8216;Weight&#8217;]) >>> print(dfMax) City [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":252704,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-252706","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-english"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts\/252706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/comments?post=252706"}],"version-history":[{"count":0,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts\/252706\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/media\/252704"}],"wp:attachment":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/media?parent=252706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/categories?post=252706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/tags?post=252706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}