Contents
List of Figures
Guide
Pagebreaks of the print version
CONTENTS IN DETAIL
- 1
PYTHON REFRESHER - 2
PYCHARM TUTORIAL - 3
A CRASH COURSE IN PANDAS - 4
FIRST DASH APP - 5
GLOBAL DATA ANALYSIS: ADVANCED LAYOUTS AND GRAPHS - 6
INVESTMENT PORTFOLIO: BUILDING LARGER APPS - 7
EXPLORING MACHINE LEARNING - 8
TIPS AND TRICKS
THE BOOK OF DASH
Build Dashboards with Python and Plotly
by Adam Schroeder, ChristianMayer,and AnnMarie Ward
THE BOOK OF DASH. Copyright 2022 by Adam Schroeder, Christian Mayer, and Ann Marie Ward.
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.
First printing
26 25 24 23 221 2 3 4 5
ISBN-13: 978-1-7185-0222-2 (print)
ISBN-13: 978-1-7185-0223-9 (ebook)
Publisher: William Pollock
Managing Editor: Jill Franklin
Production Manager: Rachel Monaghan
Production Editor: Jennifer Kepler
Developmental Editor: Liz Chadwick
Cover Illustrator: Gina Redman
Interior Design: Octopod Studios
Technical Reviewer: Tom Begley
Copyeditor: Audrey Doyle
Production Services: Westchester Publishing Services
Proofreader: Rachel Head
Indexer: BIM Creatives, LLC
For information on distribution, bulk sales, corporate sales, or translations, please contact No Starch Press, Inc. directly at or:
No Starch Press, Inc. 245 8th Street, San Francisco, CA 94103 phone: 1.415.863.9900 www.nostarch.com
Library of Congress Control Number: 2022020454
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. 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 As Is basis, without warranty. While every precaution has been taken in the preparation of this work, neither the authors nor No Starch Press, Inc. 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.
To Isabel, my beloved wife.
Adam
About the Authors
Adam Schroeder has been teaching Plotly Dash for over two years on YouTube as @CharmingData. His videos have over 60,000 views per month. Adam is passionate about helping people learn data visualization. He has an MA in government and conflict resolution and works for Plotly.
Christian Mayer has a PhD in computer science and is the founder of the popular Python site Finxter.com, an educational platform that helps more than 5 million people a year learn to code. He has published a number of books, including the Coffee Break Python series, and is the author of Python One-Liners (No Starch Press, 2020) and The Art of Clean Code (No Starch Press, 2022).
Ann Marie Ward is a Dash contributor and a moderator on the Dash community forum. Ann Marie has a BA in economics and is a retired CEO. She discovered Dash when searching for a better way to analyze financial data and was so amazed by whats possible to create with Dash that she started to learn Python, JavaScript, and R. Her contributions to Dash include improving documentation, fixing bugs, and adding features.
About the Technical Reviewer
Tom Begley is a data scientist and the co-creator and maintainer of dash-bootstrap-components. He has a PhD in mathematics and five years of experience working as a data scientist in industry. He discovered Dash when looking for ways to build interactive data visualizations for his clients, and has since become an active contributor to the Dash community and ecosystem.
ACKNOWLEDGMENTS
Putting together a programming book like this is a group effort that builds on the ideas and contributions of many people.
First and foremost, we want to thank you, the reader, for spending your valuable time with us. Our main goal is to make reading this book worth your while and, hopefully, get you as excited as we are about creating your own dashboard applications.
We would also like to thank the Plotly Dash community members for making the Plotly forum a thriving place. Over the years, weve learned a lot from the forum and honed our Dash skills thanks to the curiosity and constant support of the community.
Our deep gratitude goes to the wonderful team at No Starch Press for making the book writing process such a delightful experience. Special thanks to our outstanding editor, Liz Chadwick, for being there for us throughout the project. Liz truly is a one-of-a-kind editor, and were very lucky to have had her support! Jennifer Kepler, our production editor, pushed this book from rough draft to final publication, which was not an easy endeavorthanks a million, Jennifer! Our technical reviewer, Tom Begley, helped us significantly improve this book by contributing his impressive technical programming and Dash expertise. Moreover, were thankful to Bill Pollock, founder of No Starch Press, for believing in our project and allowing us to contribute to his inspiring mission to educate more coders.
Lastly, were very grateful to our beloved partners for enduring the long night and weekend shifts to work on this project.
And with that, lets get started!
INTRODUCTION
Information is power, some say. Data is the new gold, others proclaim. But raw information and data are often meaningless without context. Data is a valuable asset only when properly analyzed, interpreted, and understood. As a result, new fields proliferate. Data scientist, data engineer, data analyst, business intelligence consultant, and machine learning engineer are all increasingly popular careers, and they all share a common role: interpreting data using visual tools such as graphs and dashboards.
The goal of this book is to help you create beautiful dashboard apps so that you can visualize your data with just a few lines of code. Whether youre an aspiring professional, you work with data on a regular basis, or you just love to play with numbers, this book will give you the tools and education to harness the power of data.
Why This Book
The Plotly Dash framework makes it super easy for you to build your own dashboards. Dashboards are web apps that allow you and your users to dynamically explore data using interactive widgets that receive user input to explain output. For example, they might have sliders, text fields, buttons, and dropdown menus to allow the user to choose what data to show in the resultant charts and graphs, like the maps and bar charts you see in . The interactivity of dashboard apps is what has made them increasingly popular in recent years.