Prototyping Python Dashboards for Scientists and Engineers: Build and Deploy a Complete Dashboard with Python 1st Edition Houlahan download
Prototyping Python Dashboards for Scientists and Engineers: Build and Deploy a Complete Dashboard with Python 1st Edition Houlahan download
https://textbookfull.com/product/prototyping-python-dashboards-
for-scientists-and-engineers-build-and-deploy-a-complete-
dashboard-with-python-1st-edition-houlahan/
https://textbookfull.com/product/programming-with-python-for-
social-scientists-1st-edition-phillip-brooker/
https://textbookfull.com/product/django-for-beginners-build-
websites-with-python-and-django-william-s-vincent/
https://textbookfull.com/product/introduction-to-machine-
learning-with-python-a-guide-for-data-scientists-andreas-c-
muller/
https://textbookfull.com/product/introduction-to-machine-
learning-with-python-a-guide-for-data-scientists-1st-edition-
andreas-c-muller/
Python for Scientists 2nd Edition John M. Stewart
https://textbookfull.com/product/python-for-scientists-2nd-
edition-john-m-stewart/
https://textbookfull.com/product/python-programming-and-
numerical-methods-a-guide-for-engineers-and-scientist-1st-
edition-qingkai-kong/
https://textbookfull.com/product/violent-python-a-cookbook-for-
hackers-forensic-analysts-penetration-testers-and-security-
engineers-1st-edition-oconnor/
https://textbookfull.com/product/a-python-data-analysts-toolkit-
learn-python-and-python-based-libraries-with-applications-in-
data-analysis-and-statistics-gayathri-rajagopalan/
https://textbookfull.com/product/programming-for-computations-
python-a-gentle-introduction-to-numerical-simulations-with-
python-3-6-svein-linge/
Prototyping Python
Dashboards for
Scientists and
Engineers
Padraig Houlahan
Padraig Houlahan
https://doi.org/10.1007/979-8-8688-0221-8
While the advice and information in this book are believed to be true
and accurate at the date of publication, neither the authors nor the
editors nor the publisher can accept any legal responsibility for any
errors or omissions that may be made. The publisher makes no
warranty, express or implied, with respect to the material contained
herein.
New York Plaza, Suite 4600, New York, NY 10004-1562, USA. Phone
1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science +
Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is
a Delaware corporation.
Table of Contents
Dictionaries
�������������������������������
�������������������������������
�������������������������������
��������9
Series
�������������������������������
�������������������������������
�������������������������������
���������������11
Dataframes
�������������������������������
�������������������������������
�������������������������������
�������12
Summary���������������������������
�������������������������������
�������������������������������
��������������������25
Summary���������������������������
�������������������������������
�������������������������������
��������������������38
Table of ConTenTs
Summary���������������������������
�������������������������������
�������������������������������
��������������������51
Overview
�������������������������������
�������������������������������
�������������������������������
����������������53
Project Tasks
�������������������������������
�������������������������������
�������������������������������
����������57
Other Design
Considerations�������������������������
�������������������������������
�����������������������61
Summary���������������������������
�������������������������������
�������������������������������
��������������������62
Initialization
�������������������������������
�������������������������������
�������������������������������
������70
Class Methods
�������������������������������
�������������������������������
�������������������������������
��73
Summary���������������������������
�������������������������������
�������������������������������
��������������������88
Chapter 6: Dashboard
Enhancements�������������������������
������������������������89
Summary���������������������������
�������������������������������
�������������������������������
������������������114
vi
Table of ConTenTs
Using uWSGI
�������������������������������
�������������������������������
�������������������������������
���������121
Using GUNICORN
�������������������������������
�������������������������������
�������������������������������
��122
Summary���������������������������
�������������������������������
�������������������������������
������������������123
Summary���������������������������
�������������������������������
�������������������������������
������������������137
Tables
�������������������������������
�������������������������������
�������������������������������
��139
Summary���������������������������
�������������������������������
�������������������������������
������������������149
Troubleshooting WordPress
�������������������������������
�������������������������������
�����������������155
Summary���������������������������
�������������������������������
�������������������������������
������������������162
Analysis
�������������������������������
�������������������������������
������������������������������163
Incorporating Models
�������������������������������
�������������������������������
��������������������������173
vii
Table of ConTenTs
Summary���������������������������
�������������������������������
�������������������������������
������������������181
Index
�������������������������������
�������������������������������
�������������������������������
����197
viii
About the Author
ix
and ecommerce.
xi
Acknowledgments
While writing this book was a solitary endeavor, it could not have
happened without the influence of an ecosystem of family and friends
who help me keep my sanity, an ecosystem that includes the
following people.
My friends Bill Burke (a superb luthier and musician) and his wife Pat
(who meticulously documents historic archeological sites) for their
regular wonderful conversations – on all things; and close friends Tim
Sober and Carol Kennedy, Barry Malpas and his wife Anne Wittke,
and Klaus Brasch for our regular conversations and sanity-saving
rambling social and political reviews.
xiii
aCknowledgmenTs
And I must also mention Dr. Darrel Smith, a long-time friend and
professor of Physics, Dr. Jules Yimga (Chair, School of Business), and
Dr.
xiv
Introduction
I wrote this book for a past me. I’m now retired but have maintained
a lifelong interest in programming; there’s just something very
satisfying in developing a piece of code that solves a problem.
Frankly, it’s empowering; you have a solution that gets the job done.
I have had the good fortune of having worked on software projects
that were done mainly to support academic research – research in
astronomy and aviation-related studies, which have been my main
interests – not programming.
Sometimes, it’s the journey, but for me, it’s mainly the destination.
Being able to code is simply a necessary skill. It’s the norm for
academic types to write unique custom software tailored to a specific
purpose or a narrowly crafted dataset. University departments,
whether scientific or business or engineering, will rarely devote time
to teaching graduate student workers and young faculty to program;
they are expected to sink or swim. They will write code that would
fail to consider multitudes of possible scenarios or input format, for
example. “Need to enter a number?
Well, make sure you use three significant digits for that column, or
the code might crash!” – this probably happens more often than
many would like to admit. The point here is not to assign blame, but
to be realistic; very often, code is written in a very functional, get-it-
done style, to simply… get it done. It’s not about being the cleverest
or the fastest, but simply getting to the destination.
xv
InTroduCTIon
There have been many times when I found myself in such a position
and wished I had some complete examples to look at, to see how
things were done, and so this is the sense in which I say this book is
written to a past me. In showing how a dashboard was built around
an important aviation dataset, I hope I can help others benefit and
expedite their own projects without facing the often-daunting
headwinds of learning new technologies and techniques all by
themselves.
Why Dashboards?
—Fred R. Barnard
All data is ultimately a collection of bits – ones and zeros really. It can
be stored in various forms from disks to paper, but to be useful it
needs to be understood and accessible, both of which benefit from
being able to readily visualize what the data represents and from
being able to analyze and share it. Dashboards (graphical displays
using features like buttons, sliders, menus, and graphics) have
emerged as powerful tools to address these needs. When well
designed, you can encapsulate the problems xvi
InTroduCTIon
There are multiple ways a dashboard might be built and accessed like
web based, application based, and desktop based. A web-based
dashboard has an advantage as it offers freedom to the developer to
maintain an operating system–specific environment and
configurations. This makes them more stable and greatly simplifies
the development process – the designer only needs to develop for a
single platform. At the same time, the distribution problem is solved.
A dashboard on a server can be shared with any other computer on
the Internet.
Good dashboard projects are therefore a reflection of carefully
planned data analysis, reduction, presentation, management, and
dissemination.
xvii
InTroduCTIon
The main dashboard we will build in this book allows the user to
explore the government’s airport operations dataset (ATADS) that
tracks various types of daily operations for more than 500 US
airports. Operations include the kind of flights (military, civilian,
commercial), the conditions (whether they were conducted using
Instrument Flight Rules [IFR] or Visual Flight Rules [VFR]), and
whether they were local or itinerant. VFR operations are permitted
when the weather conditions meet certain minimum visibility and
cloud clearance criteria and are normally used by private pilots and
small air taxi or commercial companies. One cannot assume IFR
flights happen under inclement weather since larger commercial
airlines will use these by default for safety.
InTroduCTIon
usefulness, and it is hoped that all readers will appreciate how what
might be perceived as a fairly dry dataset actually presents wonderful
opportunities for, and naturally suggests, topics for further
exploration.
This book is intended for those who work with data and also have the
need to share insights regarding data. An essential aspect is a desire
to help their end user “lift the veil” and understand underlying data
features such as trends and patterns. Large organizations can have
teams of developers and experts to achieve these goals, but many
who could benefit from such capability (e.g., college faculty and
graduate students) work with minimal resources and need to take a
jack-of-all-trades approach to building applications; they need to
solve the data access, data importation, data display, analytical tool
build, server operating system management, and deployment
problems (if your dashboard is wildly successful, you will need a
scalable solution!). All these must be done in a realistic manner.
InTroduCTIon
There are many online resources that can show you how to make a
simple dashboard or that offer solutions created by others that can
be licensed. There are few, if any, that demonstrate a complete
solution incorporating real-world data access and download,
comprehensive reactive programming, and server configuration
issues. The obvious reason is that it takes a considerable effort to
organize and present such a complete overview, such as this work,
and this is beyond the scope of most online articles. Perhaps not too
unfairly, many online examples teach how to draw a stickman when
what you really need to know is how to do a portrait.
xx
InTroduCTIon
I will note that dashboards will evolve. In other words, you don’t
have to achieve every desirable outcome in your first attempt. Start
with a simple goal such as displaying a time series of a single data
type.
Figure out how to import and display the data; at this point, you have
made significant inroads into the I/O and graphics display problem.
Next, start adding tools like linear models for trend analysis or panels
to display important statistical values. And that’s it! Well, almost. As
you work with your data and your dashboard, you probably will have
“Aha!”
moments where new ways to visualize the data pop into your mind,
and so displays will have to be modified or new tools created. The
project will evolve. However, even as large datasets are continuously
updated, their corresponding dashboards should eventually stabilize.
Done right, this is a wonderful outcome for any research project, a
resource to be shared with end users – public or academic. And let’s
not forget the benefits your colleagues will gain by not having to
reinvent the wheel.
xxi
InTroduCTIon
Python dashboard.
• As a template: Here, you would download the code
xxii
InTroduCTIon
"The next thing that I will show you," says the author, "is this
particularity of law. In this consolidation which we call wedlock
is a locking together. It is true, that man and wife are one
person; but understand in what manner. When a small brooke
or little river incorporateth with Rhodanus, Humber, or the
Thames, the poore rivulet looseth her name; it is carried and
recarried with the new associate; it beareth no sway; it
possesseth nothing during coverture. A woman, as soon as she
is married, is called covert; in Latine, nupta,—that is, 'veiled;' as
it were, clouded and overshadowed: she hath lost her streame.
I may more truly, farre away, say to a married woman, Her new
self is her superior; her companion, her master."
Still farther: "Eve, because she had helped to seduce her
husband, had inflicted upon her a special bane. See here the
reason of that which I touched before,—that women have no
voice in Parliament. They make no laws, they consent to none,
they abrogate none. All of them are understood either married
or to be married, and their desires are to their husbands. I know
no remedy, though some women can shift it well enough. The
common lawe here shaketh hand with divinitye."
In this plain statement of the old black-letter book lies the root of
the evil with which we contend: "All of them are married or to bee
married, and their desires are to their husbands." Woman, single,
widowed, or pursuing an independent vocation, never seems to have
entered the head of the law, as a possible monster worth providing
for. The world of that day believed in the sea-serpent, but not in her.
This book, "The Lawe's Resolution of the Rights of Woman," was, so
far as I know, first brought under our notice by Mrs. Bodichon's
quotation, in her "Brief Summary of the English Law." Then a few
copies found their way to this country, and into the hands of curious
persons. People began to wonder who wrote the quaint old book. In
pleading before our own Legislature in the spring of 1858, I was
myself asked by the committee who was its author; and I think it but
right to rescue from oblivion the probable name of this early friend
to woman and justice. It is always difficult to trace an anonymous
book, and, this time, more difficult than usual, as it was probably
published after its author's death.
Sir John Doderidge, to whom my attention was directed by an
eminent antiquarian, was an able lawyer, and an industrious
compiler of law-books of a special kind. He was from Devonshire,
and admitted as a barrister in 1603. He was successively appointed
Solicitor-General, Judge of the Common Pleas and of the King's
Bench. Among the works known to be his, yet not commonly
included in the list of his works, are the "Lawyer's Light," published
in 1629; and "The Complete Parson," with the laws relating to
advowsons and livings, in 1670,—books of the same class, character,
and appearance as the "Lawe's Resolution."
As he died in 1628, I was at first inclined to suspect the fairness of
this inference: but a further examination showed that all his
publications were posthumous; which accounts, perhaps, for the
candor of their covert satire. A few particulars of his life and
standing may be gained from the new Life of Lord Bacon, where
Hepworth Dixon says that "the Solicitor-Generalship, vacant once
more, is given, over Francis Bacon's head, to Sir John Doderidge,
Serjeant of the Coif." In 1606, when Sir Francis Gawdy dies, "Coke
goes up to the bench; and Doderidge, the Solicitor-General, ought,
by the custom of the law, to follow Coke, leaving the post of Solicitor
void: but Cecil raises Sir Henry Hobart, his obscure Attorney of the
Court of Wards, over both Doderidge and Bacon's head, to the high
place of Attorney-General." Since that day, Bentham and Catharine
Macauley, Mary Wollstonecraft, and John Stuart Mill, have made the
same complaint; sustaining it, however, by vigorous argument for
woman's full emancipation, and a demand for the right of suffrage.
Let us look at this English law. So far as it affects single women, it is
very simple.
A single woman has the same rights of property as a man; that is,
she may get and keep, or dispose of, whatever she can. She has a
right, like man, to the protection of the law, and has to pay the
same taxes to the State.
"Duly qualified," she may vote on parish questions and for parish
officers; and "duly qualified," in England, means that she shall have
a certain amount of property, and so a vested interest in the
prosperity of her parish. If her parents die without a will, she shares
equally with her brothers in the division of the personal property;
but her eldest brother and his issue, even if female, will take the real
estate as heirs-at-law. If she be an only child, she inherits both
personal and real, and becomes immediately that most pitiable of
creatures, an heiress.
The church and all state offices are closed to women. They find
some employment in rural post-offices; but there is no important
office they can hold, if we except that of sovereign. This is
sometimes spoken of as an inconsistency; but if we reflect upon the
position of a constitutional sovereign, whose speeches are the work
of her minister, and whose actions indicate the average conscience
of a cabinet council, we shall find her legally but very little more
independent than other women technically classed with minors and
idiots.
There have been a few women governors of prisons, overseers of
the poor, and parish clerks; but public opinion still effectually bars
most women from seeking or accepting office.
The office of Grand Chamberlain was filled by two women in 1822.
That of Clerk of the Crown, in the Court of Queen's Bench, has been
granted to a female; and, in a certain parish of Norfolk, a woman
was recently appointed parish clerk, because, in a population of six
hundred souls, no man could be found able to read and write!
In an action at law, it has been determined that an unmarried
woman, having a freehold, might vote for members of Parliament.
Mr. Higginson tells us that a certain Lady Packington returned two.
In all periods, there have been women who have held exceptional
positions, under peculiar influence of wealth or rank or
circumstances; and though this has not affected the position of other
women, or given them any more freedom, yet it is valuable in itself,
because it has kept the possibility of their employment always open,
and acted like a practical protest against the law.
The Countess of Pembroke was hereditary Sheriff of Westmoreland,
and exercised her office. In the reign of Queen Anne, Lady Rous did
the same, "girt with a sword." Henry VIII. once granted a
commission of inquiry, under the great seal, to Lady Anne Berkeley,
who opened it at Gloucester, and passed sentence under it.
Some of the old legal writers averred, that a woman might serve in
almost any of the great offices of the kingdom. Lately we find it
stated that a woman may be elected as constable, since she can hire
a man to serve for her; but she may not be elected overseer of the
poor, because, in this case, substitution, if not impossible, would be
difficult!
What were the peculiar political excitements which enabled Lady
Packington to return two members of Parliament, we are not told;
but it is quite certain that women of twenty-one, duly qualified,
cannot and do not vote for members of Parliament by virtue of that
decision. In rural districts, where personal influence weighed a good
deal, such a vote might be courteously winked at. A woman of
property and standing, in Nova Scotia, has in this manner, for more
than forty years, cast her annual vote, without rebuke or
interruption; but, should any number of women act on this
precedent, a legal restraint would doubtless be laid.
No single woman, having been seduced, has any remedy at common
law; neither has her mother nor next friend. If her father can prove
service rendered, he may sue for loss of service.
In what "bosom of divinitye" does this law rest? Here is a remedy for
the loss of a few hours, but no penalty held up in terrorem, to warn
man that he may not trifle with honor, womanly purity, and childish
ignorance or innocence.
In the eye of this law, female chastity is only valuable for the work it
can do. It must not be thought, however, that the English common
law stands alone in this moral deformity. Under the French law,
female chastity does not seem of any worth, even in consideration of
the work it can do. In honest indignation, Legouvé exclaims,—
"I have learned the law piecemeal," she says, "by suffering all it
could inflict. I forgave my husband's wickedness again and
again, and found too late, that, in the eye of the law, practical
Christianity, the forgiving unto seventy times seven, was a
condonation which deprived me of all protection. My children
were stolen from me, and put into the vilest custody, where one
of them afterwards died for want of a mother's commonest
care. My husband brought an action against his kindest friend,
of whom he borrowed money and received office. The jury
listened with disgust, and gave their verdict against him. Then I
was told that I might write for my bread, or my family might
support me. My children were kept away, as their residence with
me would make him liable for my debts.
"When my mother died, and left me, through my brother, a
small income, he balanced the first payment by arbitrarily
stopping his own allowance. For the last three years, I have not
received a farthing from him. He retains all my personal
property which was left in his home, the gifts of the royal family
on my marriage, articles bought with my own earnings, and
presents from Lord Melbourne. He receives from my trustees
the income which my father bequeathed to me, which the 'non-
existent' wife must resign to the 'existent' husband.
"I have also the power of earning by literature; but even this
power, the gift of God, not the legacy of man, bears fruit only
for him. Let him subpœna my publishers, and enjoy his triumph:
he has shown me that I was not meant to write novels and
tales, but to rouse the nation against such men as he, and such
laws as they sustain. Let him eat the bread I earn; but it shall
be bought with the price of his own exposure. If law will not
listen to me, to literature I will devote my power, and secure for
others what I have not been able to secure for myself."
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com