0% found this document useful (0 votes)
32 views

Introduction To Python For Humanists William J B Mattingly download

Ebook access

Uploaded by

hangadendure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Introduction To Python For Humanists William J B Mattingly download

Ebook access

Uploaded by

hangadendure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

Introduction To Python For Humanists William J B

Mattingly download

https://ebookbell.com/product/introduction-to-python-for-
humanists-william-j-b-mattingly-50506048

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Introduction To Python For Engineers And Scientists Open Source


Solutions For Numerical Computation 1st Edition Sandeep Nagar

https://ebookbell.com/product/introduction-to-python-for-engineers-
and-scientists-open-source-solutions-for-numerical-computation-1st-
edition-sandeep-nagar-51197000

Introduction To Python For Kids Learn Python The Fun Way By Completing
Activities And Solving Puzzles 1st Ed Aarthi Elumalai

https://ebookbell.com/product/introduction-to-python-for-kids-learn-
python-the-fun-way-by-completing-activities-and-solving-puzzles-1st-
ed-aarthi-elumalai-32588532

Introduction To Python For Engineers And Scientists Open Source


Solutions For Numerical Computation Sandeep Nagar

https://ebookbell.com/product/introduction-to-python-for-engineers-
and-scientists-open-source-solutions-for-numerical-computation-
sandeep-nagar-6804432

Introduction To Python For Science And Engineering David J Pine

https://ebookbell.com/product/introduction-to-python-for-science-and-
engineering-david-j-pine-7395824
Introduction To Python For Science And Engineering Second Edition
David J Pine

https://ebookbell.com/product/introduction-to-python-for-science-and-
engineering-second-edition-david-j-pine-58931256

Introduction To Python For Econometrics Statistics And Data Analysis


5th Edition Kevin Sheppard

https://ebookbell.com/product/introduction-to-python-for-econometrics-
statistics-and-data-analysis-5th-edition-kevin-sheppard-53726340

Introduction To Python For Econometrics Statistics And Data Analysis


Kevin Sheppard

https://ebookbell.com/product/introduction-to-python-for-econometrics-
statistics-and-data-analysis-kevin-sheppard-11985190

Introduction To Python For Science And Engineering David J Pine

https://ebookbell.com/product/introduction-to-python-for-science-and-
engineering-david-j-pine-231847460

Computing With Python An Introduction To Python For Science And


Engineering Feuhrer

https://ebookbell.com/product/computing-with-python-an-introduction-
to-python-for-science-and-engineering-feuhrer-22059306
Introduction to Python
for Humanists

This book will introduce digital humanists at all levels of education to Python. It provides
background and guidance on learning the Python computer programming language, and
as it presumes no knowledge on the part of the reader about computers or coding concepts
allows the reader to gradually learn the more complex tasks that are currently popular in
the field of digital humanities. This book will be aimed at undergraduates, graduates, and
faculty who are interested in learning how to use Python as a tool within their workflow.
An Introduction to Python for Digital Humanists will act as a primer for students who wish
to use Python, allowing them to engage with more advanced textbooks. This book fills a
real need, as it is first Python introduction to be aimed squarely at humanities students,
as other books currently available do not approach Python from a humanities perspective.
It will be designed so that those experienced in Python can teach from it, in addition to
allowing those who are interested in being self-taught can use it for that purpose.

Key Features:

• Data analysis
• Data science
• Computational humanities
• Digital humanities
• Python
• Natural language processing
• Social network analysis
• App development
Chapman & Hall/CRC
The Python Series

About the Series


Python has been ranked as the most popular programming language, and it is widely used
in education and industry. This book series will offer a wide range of books on Python for
students and professionals. Titles in the series will help users learn the language at an
introductory and advanced level, and explore its many applications in data science, AI,
and machine learning. Series titles can also be supplemented with Jupyter notebooks.

Image Processing and Acquisition using Python, Second Edition


Ravishankar Chityala, Sridevi Pudipeddi

Python Packages
Tomas Beuzen and Tiffany-Anne Timbers

Statistics and Data Visualisation with Python


Jesús Rogel-Salazar

Introduction to Python for Humanists


William J.B. Mattingly

For more information about this series please visit: https://www.routledge.com/


Chapman--HallCRC-The-Python-Series/book-series/PYTH
Introduction to Python for
Humanists

William J.B. Mattingly


Front cover image: Ryzhi/Shutterstock

First edition published 2023


by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742

and by CRC Press


4 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN

CRC Press is an imprint of Taylor & Francis Group, LLC

© 2023 William Mattingly

Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have
attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright hold-
ers if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged
please write and let us know so we may rectify in any future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or
utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including pho-
tocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission
from the publishers.

For permission to photocopy or use material electronically from this work, access www.copyright.com or contact the
Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. For works that are not
available on CCC please contact mpkbookspermissions@tandf.co.uk

Trademark notice: Product or corporate names may be trademarks or registered trademarks and are used only for iden-
tification and explanation without intent to infringe.

Library of Congress Cataloging‑in‑Publication Data

Names: Mattingly, William J. B., author.


Title: Introduction to Python for humanists / William J.B. Mattingly.
Description: First edition. | Boca Raton : CRC Press, [2023] | Series:
Chapman & Hall/CRC the Python series | Includes bibliographical
references and index. | Identifiers: LCCN 2022056310 (print) | LCCN 2022056311 (ebook) | ISBN
9781032377902 (hbk) | ISBN 9781032378374 (pbk) | ISBN 9781003342175
(ebk)
Subjects: LCSH: Python (Computer program language) | Engineering--Data
processing. | Science--Data processing. | Computer programming.
Classification: LCC QA76.73.P98 M383 2023 (print) | LCC QA76.73.P98
(ebook) | DDC 005.13/3--dc23/eng/20221202
LC record available at https://lccn.loc.gov/2022056310
LC ebook record available at https://lccn.loc.gov/2022056311

ISBN: 978-1-032-37790-2 (hbk)


ISBN: 978-1-032-37837-4 (pbk)
ISBN: 978-1-003-34217-5 (ebk)

DOI: 10.1201/9781003342175

Typeset in Palatino LT Std


by Deanta Global Publishing Services, Chennai, India
Contents

Preface xv

Acknowledgments xix

About the Author xxi

I The Basics of Python 1


1 Introduction to Python 3
1.1 Introduction to Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.1 Why Should Humanists Learn to Code? . . . . . . . . . . . . . . . . 3
1.1.1.1 The Timeline for Starting a Large Digital History Project 3
1.1.1.2 The Self-Reliant Digital Humanist . . . . . . . . . . . . . 4
1.1.1.3 Other Benefits . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.2 What Is Python? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.3 Why Python? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 Installing Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.1 Trinket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.2 Using Google Colab . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.3 Using Binder from JupyterBook . . . . . . . . . . . . . . . . . . . . 9
1.2.4 Using Jupyter Notebooks Online . . . . . . . . . . . . . . . . . . . . 11
1.2.5 Installing Python Locally . . . . . . . . . . . . . . . . . . . . . . . . 13
1.2.5.1 Download Anaconda Navigator . . . . . . . . . . . . . . 14
1.2.5.2 Using Anaconda Navigator . . . . . . . . . . . . . . . . . 14
1.2.5.3 Installing JupyterLab . . . . . . . . . . . . . . . . . . . . . 14
1.2.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.3 Coding Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.3.1 The Print Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.3.2 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.3.3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.3.4 Case Sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.3.5 Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.3.6 Built-in Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.3.7 Type Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.3.8 Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2 Data and Data Structures 23


2.1 Introduction to Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.1.1 What Is Data? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.1.2 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.1.3 Working with Strings as Data . . . . . . . . . . . . . . . . . . . . . . 25
2.1.3.1 Upper Method . . . . . . . . . . . . . . . . . . . . . . . . . 26

v
vi Contents

2.1.3.2 Lower Method . . . . . . . . . . . . . . . . . . . . . . . . . 26


2.1.3.3 Capitalize Method . . . . . . . . . . . . . . . . . . . . . . 26
2.1.3.4 Replace Method . . . . . . . . . . . . . . . . . . . . . . . . 26
2.1.3.5 Split Method . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.1.4 Numbers (Integers and Floats) . . . . . . . . . . . . . . . . . . . . . 28
2.1.5 Working with Numbers as Data . . . . . . . . . . . . . . . . . . . . 29
2.1.6 Booleans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.1.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2 Introduction to Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2.1 Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2.2 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.2.2.1 Indexing a List . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.2.3 Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.2.4 Mutability vs Immutability . . . . . . . . . . . . . . . . . . . . . . . 33
2.2.5 Sets (Bonus Data Structure) . . . . . . . . . . . . . . . . . . . . . . . 33
2.2.6 Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.2.6.1 Indexing Dictionaries . . . . . . . . . . . . . . . . . . . . . 34

3 Loops and Logic 37


3.1 Introduction to Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1.1 What Are Loops? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1.2 For Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1.3 List Comprehension . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.1.4 Indexing a List with and without Enumerate . . . . . . . . . . . . . 40
3.1.5 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.1.6 While Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.2 Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.2.1 If Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.2.2 Else Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.2.3 Elif and the ‘in’ Operator with Strings . . . . . . . . . . . . . . . . . 44
3.2.4 Conditionals and Lists with ‘in’ and ‘not in’ . . . . . . . . . . . . . 45
3.2.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

4 Formal Coding: Functions, Classes, and Libraries 47


4.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.1.2 Functions in Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.1.3 Docstrings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.1.4 Functions with Multiple Arguments . . . . . . . . . . . . . . . . . . 49
4.1.5 Keyword Argument . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.1.6 Keyword Arbitrary Arguments . . . . . . . . . . . . . . . . . . . . . 50
4.1.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.1.8 Answer for Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.2 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.2.2 Creating a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.2.3 Adding Functions to a Class . . . . . . . . . . . . . . . . . . . . . . 53
4.3 Libraries in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.3.2 How to Install Python Libraries . . . . . . . . . . . . . . . . . . . . 54
Contents vii

4.3.3 How to Import a Library . . . . . . . . . . . . . . . . . . . . . . . . 55


4.3.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

5 Working with External Data 57


5.1 Working with Textual Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.1.2 The “With” Statement . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.1.3 How to Open a Text File . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.1.4 How to Write Data to a Text File . . . . . . . . . . . . . . . . . . . . 58
5.2 Working with JSON Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.2.2 Writing JSON Data with json.dump() . . . . . . . . . . . . . . . . . 59
5.2.3 Reading JSON data with json.load() . . . . . . . . . . . . . . . . . . 60
5.3 Working with Multiple Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.3.2 Working with Glob . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.3.3 Grabbing Multiple Nested Directories . . . . . . . . . . . . . . . . . 61
5.3.4 Walking a Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.3.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

6 Working with Data on the Web 65


6.1 Introduction to HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.1.2 Diving into HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.1.3 Understanding Attributes . . . . . . . . . . . . . . . . . . . . . . . . 66
6.1.4 Parsing HTML with BeautifulSoup . . . . . . . . . . . . . . . . . . . 66
6.1.5 How to Find a Website’s HTML . . . . . . . . . . . . . . . . . . . . 69
6.2 Scraping Web Pages with Requests and BeautifulSoup . . . . . . . . . . . . 70
6.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.2.2 Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.2.3 BeautifulSoup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

II Data Analysis with Pandas 75


7 Introduction to Pandas 77
7.1 Introduction to Pandas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
7.1.1 What Is Pandas? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
7.1.2 Why Use Pandas? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
7.1.3 How to Install Pandas . . . . . . . . . . . . . . . . . . . . . . . . . . 78
7.1.4 How to Import Pandas . . . . . . . . . . . . . . . . . . . . . . . . . . 78
7.2 The Basics of Pandas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
7.2.1 How to Create a DataFrame from a Dictionary . . . . . . . . . . . . 78
7.2.2 How to Display a DataFrame . . . . . . . . . . . . . . . . . . . . . . 79
7.2.3 How to Save DataFrame to CSV . . . . . . . . . . . . . . . . . . . . 80
7.2.4 How to Read DataFrame from CSV . . . . . . . . . . . . . . . . . . 80
7.2.5 How to Save DataFrame to JSON . . . . . . . . . . . . . . . . . . . . 81
7.2.6 How to Add a Column to the DataFrame . . . . . . . . . . . . . . . 81
7.2.7 How to Grab a Specific Column . . . . . . . . . . . . . . . . . . . . 82
7.2.8 How to Convert a Column to a List . . . . . . . . . . . . . . . . . . 83
7.2.9 Isolating Unique Values in a Column . . . . . . . . . . . . . . . . . 83
7.2.10 How to Grab a Specific Row of a DataFrame with iloc . . . . . . 83
viii Contents

7.2.11 Iterating over a DataFrame with df.iterrows() . . . . . . . . . . . . 84


7.2.12 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

8 Working with Data in Pandas 85


8.1 Finding Data in DataFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
8.1.1 About the Titanic Dataset . . . . . . . . . . . . . . . . . . . . . . . . 85
8.1.2 How to Find Column Data . . . . . . . . . . . . . . . . . . . . . . . 85
8.1.3 How to Get a Quick Sense of the Dataset with df.head() . . . . . . 86
8.1.4 How to Grab a Specific Range of Rows with df.iloc[] . . . . . . 88
8.1.5 How to Get a Quick Quantitative Understanding of the Dataset with
describe() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
8.1.6 How to Find Specific Information in the Dataset with df.loc . . . 89
8.1.7 How to Query with “OR” (|) on a DataFrame . . . . . . . . . . . . . 93
8.2 Organizing the DataFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
8.2.1 How to Sort Data By Single Column . . . . . . . . . . . . . . . . . . 95
8.2.2 How to Reverse Sort Data by Single Column . . . . . . . . . . . . . 97
8.2.3 How to Sort Data by Multiple Columns . . . . . . . . . . . . . . . . 98
8.2.4 How to Sort Data by Multiple Columns with Different Values Orga-
nized Differently . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.3 Cleaning the DataFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
8.3.1 How to Drop a Column in Pandas DataFrame . . . . . . . . . . . . 101
8.3.2 How to Remove Rows That Have NaN in Any Column . . . . . . . 104
8.3.3 How to Remove Rows That Have NaN in a Specific Column . . . . 104
8.3.4 How to Convert DataFrame Data Types (from Float to Int) . . . . . 105
8.3.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

9 Searching for Data 109


9.1 Advanced Searching on Strings . . . . . . . . . . . . . . . . . . . . . . . . . 109
9.1.1 Finding Features within a String . . . . . . . . . . . . . . . . . . . . 109
9.1.2 Finding Strings That Don’t Contain Feature . . . . . . . . . . . . . 110
9.1.3 Using RegEx with Pandas . . . . . . . . . . . . . . . . . . . . . . . . 110
9.2 Filter and Querying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
9.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
9.2.2 The Filter Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
9.2.3 The Query Function . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
9.3 Grouping with groupby() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.3.2 groupby() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.3.3 Quantitative Analysis with .count() and .sum() . . . . . . . . . 122
9.3.4 Working with Multiple Groups . . . . . . . . . . . . . . . . . . . . . 123
9.3.5 Groupings with Many Subsets . . . . . . . . . . . . . . . . . . . . . 124

10 Advanced Pandas 125


10.1 Plotting Data with Pandas . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
10.1.1 Importing the DataFrame . . . . . . . . . . . . . . . . . . . . . . . . 125
10.1.2 Bar and Barh Charts with Pandas . . . . . . . . . . . . . . . . . . . 126
10.1.3 Pie Charts with Pandas . . . . . . . . . . . . . . . . . . . . . . . . . 128
10.1.4 Scatter Plots with Pandas . . . . . . . . . . . . . . . . . . . . . . . . 130
10.2 Graphing Network Data with Pandas . . . . . . . . . . . . . . . . . . . . . 138
10.2.1 Getting the Data from Pandas to NetworkX . . . . . . . . . . . . . . 138
10.2.2 Graphing the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Contents ix

10.2.3 Customize the Graph . . . . . . . . . . . . . . . . . . . . . . . . . . 139


10.3 Time Series Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
10.3.1 What Is Time Series Data . . . . . . . . . . . . . . . . . . . . . . . . 141
10.3.2 About the Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
10.3.3 Cleaning the Data from Float to Int . . . . . . . . . . . . . . . . . . 143
10.3.4 Convert to Time Series DateTime in Pandas . . . . . . . . . . . . . . 149

III Natural Language Processing with spaCy 155


11 Introduction to Spacy 157
11.1 The Basics of spaCy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
11.1.1 What Is spaCy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
11.1.2 How to Install spaCy . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
11.1.3 Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
11.2 Getting Started with spaCy and Its Linguistic Annotations . . . . . . . . . 159
11.2.1 Importing spaCy and Loading Data . . . . . . . . . . . . . . . . . . 159
11.2.2 Creating a Doc Container . . . . . . . . . . . . . . . . . . . . . . . . 160
11.2.3 Sentence Boundary Detection (SBD) . . . . . . . . . . . . . . . . . . 162
11.2.4 Token Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
11.2.4.1 Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
11.2.4.2 Head . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
11.2.4.3 Left Edge . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
11.2.4.4 Right Edge . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
11.2.4.5 Entity Type . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
11.2.4.6 Ent IOB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
11.2.4.7 Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
11.2.4.8 Morph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
11.2.4.9 Part of Speech . . . . . . . . . . . . . . . . . . . . . . . . . 165
11.2.4.10 Syntactic Dependency . . . . . . . . . . . . . . . . . . . . 166
11.2.4.11 Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
11.2.5 Part-of-Speech (POS) Tagging . . . . . . . . . . . . . . . . . . . . . . 166
11.2.6 Named Entity Recognition (NER) . . . . . . . . . . . . . . . . . . . 167
11.2.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
11.3 spaCy’s Pipelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
11.3.1 Standard Pipes (Components and Factories) Available from spaCy 168
11.3.1.1 Attribute Rulers . . . . . . . . . . . . . . . . . . . . . . . . 169
11.3.1.2 Matchers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
11.3.2 How to Add Pipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
11.3.3 Examining a Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
11.3.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

12 Rules-Based spaCy 173


12.1 The EntityRuler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
12.1.1 Introduction to spaCy’s EntityRuler . . . . . . . . . . . . . . . . . . 173
12.1.2 Demonstration of EntityRuler in Action . . . . . . . . . . . . . . . . 173
12.1.3 Introducing Complex Rules and Variance to the EntityRuler
(Advanced) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
12.2 The Matcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
12.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
12.2.2 A Basic Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
12.2.3 Attributes Taken by Matcher . . . . . . . . . . . . . . . . . . . . . . 179
x Contents

12.2.4Applied Matcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180


12.2.4.1 Grabbing all Proper Nouns . . . . . . . . . . . . . . . . . 181
12.2.4.2 Improving it with Multi-Word Tokens . . . . . . . . . . . 181
12.2.4.3 Greedy Keyword Argument . . . . . . . . . . . . . . . . . 181
12.2.4.4 Adding in Sequences . . . . . . . . . . . . . . . . . . . . . 182
12.3 The PhraseMatcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
12.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
12.3.2 Setting a Custom Attribute . . . . . . . . . . . . . . . . . . . . . . . 184
12.3.3 Adding a Function with on_match . . . . . . . . . . . . . . . . . . 185
12.4 Using RegEx with spaCy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
12.4.1 What Is Regular Expressions (RegEx)? . . . . . . . . . . . . . . . . . 186
12.4.2 The Strengths of RegEx . . . . . . . . . . . . . . . . . . . . . . . . . 186
12.4.3 The Weaknesses of RegEx . . . . . . . . . . . . . . . . . . . . . . . . 186
12.4.4 How to Use RegEx in Python . . . . . . . . . . . . . . . . . . . . . . 186
12.4.5 How to Use RegEx in spaCy . . . . . . . . . . . . . . . . . . . . . . 188
12.5 Working with Multi-Word Token Entities and RegEx in spaCy 3x . . . . . 191
12.5.1 Key Concepts in This Notebook . . . . . . . . . . . . . . . . . . . . 191
12.5.2 Problems with Multi-Word Tokens in spaCy as Entities . . . . . . . 191
12.5.3 Extract Multi-Word Tokens . . . . . . . . . . . . . . . . . . . . . . . 191
12.5.4 Reconstruct Spans . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
12.5.5 Inject the Spans into the doc.ents . . . . . . . . . . . . . . . . . . . . 192
12.5.6 Give Priority to Longer Spans . . . . . . . . . . . . . . . . . . . . . . 193

13 Solving a Domain-Specific Problem: A Case Study with Holocaust NER 195


13.1 Cultivating Good Datasets for Entities . . . . . . . . . . . . . . . . . . . . . 195
13.1.1 Introduction to Datasets . . . . . . . . . . . . . . . . . . . . . . . . . 195
13.1.2 Acquiring the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
13.1.3 United States Holocaust Memorial Museum . . . . . . . . . . . . . 195
13.1.4 Normalizing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
13.2 The Challenges of Holocaust NER . . . . . . . . . . . . . . . . . . . . . . . 197
13.2.1 An Overview of the Problems . . . . . . . . . . . . . . . . . . . . . . 197
13.2.2 Ethical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
13.2.3 Linguistic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
13.2.4 Toponyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
13.3 Creating a Rules-Based Pipeline for Holocaust Documents . . . . . . . . . 198
13.3.1 Creating a Blank spaCy Model . . . . . . . . . . . . . . . . . . . . . 199
13.3.2 Creating EntityRulers . . . . . . . . . . . . . . . . . . . . . . . . . . 199
13.3.3 Creating Function for Matching RegEx . . . . . . . . . . . . . . . . 200
13.3.4 Add Pipe for Finding Streets . . . . . . . . . . . . . . . . . . . . . . 202
13.3.5 Creating a Pipe for Finding Ships . . . . . . . . . . . . . . . . . . . 203
13.3.6 Create Pipe for Identifying a Military Personnel . . . . . . . . . . . 205
13.3.7 Create Pipe for Identifying Spouses . . . . . . . . . . . . . . . . . . 205
13.3.8 Creating a Pipe for Finding Ghettos . . . . . . . . . . . . . . . . . . 206
13.3.9 Creating a Geography Pipe . . . . . . . . . . . . . . . . . . . . . . . 206
13.3.10 Seeing the Pipes at Work . . . . . . . . . . . . . . . . . . . . . . . . . 207

14 Topic Modeling: Concepts and Theory 211


14.1 What Is Topic Modeling? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
14.1.1 Rules-Based Methods . . . . . . . . . . . . . . . . . . . . . . . . . . 212
14.1.2 Machine Learning-Based Methods . . . . . . . . . . . . . . . . . . . 212
Contents xi

14.1.3 Why Use Topic Modeling? . . . . . . . . . . . . . . . . . . . . . . . 213


14.2 Topics and Clusters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
14.2.1 What Are Topics? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
14.2.2 What Are Clusters? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
14.3 Bigrams and Trigrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
14.3.1 Textual Ambiguity . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
14.3.2 Bigrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
14.3.3 Trigrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
14.3.4 Why Are These Important? . . . . . . . . . . . . . . . . . . . . . . . 215
14.4 LDA Topic Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
14.4.1 Process of Topic Modeling . . . . . . . . . . . . . . . . . . . . . . . . 215
14.4.2 Knowing the Total Number of Topics . . . . . . . . . . . . . . . . . 217
14.4.3 Applying a Topic Model . . . . . . . . . . . . . . . . . . . . . . . . . 218
14.4.4 Summary of Key Issues with LDA Topic Modeling . . . . . . . . . 218
14.5 Creating LDA in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
14.5.1 Importing the Required Libraries and Data . . . . . . . . . . . . . . 218
14.5.2 Cleaning Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
14.5.3 Create ID-Word Index . . . . . . . . . . . . . . . . . . . . . . . . . . 220
14.5.4 Creating LDA Topic Model . . . . . . . . . . . . . . . . . . . . . . . 222
14.5.5 Analyze a Document . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
14.5.6 Analyze the Topic Model . . . . . . . . . . . . . . . . . . . . . . . . 224
14.6 Transformer Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
14.6.1 Importing Libraries and Gathering Data . . . . . . . . . . . . . . . 225
14.6.2 Embedding the Documents . . . . . . . . . . . . . . . . . . . . . . . 226
14.6.3 Flattening the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
14.6.4 Isolating Clusters with HDBScan . . . . . . . . . . . . . . . . . . . . 227
14.6.5 Analyzing the Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
14.6.6 Outliers (Noise) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
14.7 Top2Vec in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
14.7.1 Creating a Top2Vec Model . . . . . . . . . . . . . . . . . . . . . . . . 231
14.7.2 Analyzing Our Topic Model . . . . . . . . . . . . . . . . . . . . . . . 232
14.7.3 Working with Bigrams and Trigrams . . . . . . . . . . . . . . . . . . 235
14.7.4 Saving and Loading a Top2Vec Model . . . . . . . . . . . . . . . . . 236

15 Text Analysis with BookNLP 239


15.1 Introduction to BookNLP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
15.1.1 What Is BookNLP? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
15.1.2 Why Books and Larger Documents? . . . . . . . . . . . . . . . . . . 240
15.1.3 How to Install BookNLP . . . . . . . . . . . . . . . . . . . . . . . . . 241
15.2 Getting Started With BookNLP . . . . . . . . . . . . . . . . . . . . . . . . . 241
15.2.1 Importing BookNLP and Creating a Pipeline . . . . . . . . . . . . . 241
15.2.2 Setting up the File and Directories . . . . . . . . . . . . . . . . . . . 242
15.2.3 Running the Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
15.3 The Output Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
15.3.1 The .tokens File . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
15.3.2 The .entities File . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
15.3.3 The .quotes File . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
15.3.4 The .supersense File . . . . . . . . . . . . . . . . . . . . . . . . . 248
15.3.5 The .book File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
15.3.6 The .book.html File . . . . . . . . . . . . . . . . . . . . . . . . . . 251
xii Contents

15.4 Character Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252


15.4.1 Analyzing the Characters (From BookNLP Repo) . . . . . . . . . . 252
15.4.2 Parsing Verb Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
15.5 Events Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
15.5.1 Exploring the Tokens File . . . . . . . . . . . . . . . . . . . . . . . . 256
15.5.2 Grabbing the Events . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
15.5.3 Analyzing Events Words and Lemmas . . . . . . . . . . . . . . . . 258
15.5.4 Grabbing Event Sentences . . . . . . . . . . . . . . . . . . . . . . . . 259
15.5.5 Bringing Everything Together . . . . . . . . . . . . . . . . . . . . . . 260
15.5.6 Creating an .events File . . . . . . . . . . . . . . . . . . . . . . . . 261
15.5.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

16 Social Network Analysis 263


16.1 The Basic Concepts of Social Network Analysis . . . . . . . . . . . . . . . . 263
16.1.1 Basic Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
16.1.2 SNA Libraries in Python . . . . . . . . . . . . . . . . . . . . . . . . . 264
16.2 Introduction to NetworkX . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
16.2.1 Adding All Edges at Once . . . . . . . . . . . . . . . . . . . . . . . . 265
16.2.2 Asymmetrical Networks . . . . . . . . . . . . . . . . . . . . . . . . . 266
16.2.3 Calculating Shortest Distance . . . . . . . . . . . . . . . . . . . . . . 267
16.2.4 Calculating Connections . . . . . . . . . . . . . . . . . . . . . . . . . 268
16.2.5 Identifying Major Actors in a Network . . . . . . . . . . . . . . . . 268
16.2.6 Limitations of Matplotlib and NetworkX . . . . . . . . . . . . . . . 268
16.3 Producing Dynamic Graphs with PyVis . . . . . . . . . . . . . . . . . . . . 269
16.3.1 The Basics of PyVis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
16.4 NetworkX and PyVis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
16.5 Adding Color to Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
16.6 SNA on Humanities Data: Structuring the Data . . . . . . . . . . . . . . . . 273
16.6.1 Examining the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
16.7 SNA on Humanities Data: Creating the Graph . . . . . . . . . . . . . . . . 276
16.7.1 Building the Network . . . . . . . . . . . . . . . . . . . . . . . . . . 277
16.7.2 Visualizing the Network . . . . . . . . . . . . . . . . . . . . . . . . . 277
16.7.3 Adding Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
16.7.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

IV Designing an Application with Streamlit 283


17 Introduction to Streamlit 285
17.1 Creating Our First App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
17.1.1 Options for Application Development in Python . . . . . . . . . . . 285
17.1.2 Installing Streamlit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
17.1.3 Creating a Home Page . . . . . . . . . . . . . . . . . . . . . . . . . . 286
17.2 Displaying Data in Streamlit . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
17.2.1 Displaying Text to Users . . . . . . . . . . . . . . . . . . . . . . . . . 287
17.2.2 Displaying Python Data Structures . . . . . . . . . . . . . . . . . . . 289
17.2.2.1 Data Structures with st.write() . . . . . . . . . . . . . 289
17.2.2.2 Data Structures with st.json() . . . . . . . . . . . . . . 289
17.2.3 Displaying Tabular Data . . . . . . . . . . . . . . . . . . . . . . . . . 289
17.2.3.1 Tabular Data with st.write() . . . . . . . . . . . . . . 290
17.2.3.2 Tabular Data with st.dataframe() . . . . . . . . . . . 290
17.2.3.3 Tabular Data with st.table() . . . . . . . . . . . . . . 291
Contents xiii

17.2.3.4 Tabular Data with st.markdown() . . . . . . . . . . . . 291


17.2.4
Displaying Multimedia in Streamlit . . . . . . . . . . . . . . . . . . 291
17.2.4.1 Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
17.2.4.2 Audio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
17.2.4.3 Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
17.3 Streamlit Input Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
17.3.1 Text Input Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
17.3.1.1 st.text_input() . . . . . . . . . . . . . . . . . . . . . . . . . 293
17.3.1.2 st.text_area() . . . . . . . . . . . . . . . . . . . . . . . . . . 293
17.3.2 Numerical Input Widgets . . . . . . . . . . . . . . . . . . . . . . . . 294
17.3.2.1 st.number_input() . . . . . . . . . . . . . . . . . . . . . . . 294
17.3.2.2 st.slider() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
17.3.3 Date and Time Input Widgets . . . . . . . . . . . . . . . . . . . . . . 295
17.3.3.1 st.date_input() . . . . . . . . . . . . . . . . . . . . . . . . . 295
17.3.3.2 st.time_input() . . . . . . . . . . . . . . . . . . . . . . . . . 296
17.3.4 Boolean Input Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . 296
17.3.4.1 st.checkbox() . . . . . . . . . . . . . . . . . . . . . . . . . . 297
17.3.4.2 st.button() . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
17.3.5 Selection Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
17.3.5.1 st.radio() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
17.3.5.2 st.selectbox() . . . . . . . . . . . . . . . . . . . . . . . . . . 298
17.3.5.3 st.multiselect() . . . . . . . . . . . . . . . . . . . . . . . . . 299

18 Advanced Streamlit Features 301


18.1 Data Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
18.1.1 Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
18.1.2 Plotting Basic Graphs with Streamlit . . . . . . . . . . . . . . . . . . 302
18.1.2.1 Line Charts with st.line_chart() . . . . . . . . . . . 303
18.1.2.2 Bar Charts with st.bar_chart() . . . . . . . . . . . . . 303
18.1.2.3 Area Charts with st.area_chart() . . . . . . . . . . . 303
18.1.3 Map Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
18.1.3.1 Creating Maps with st.map() . . . . . . . . . . . . . . . 305
18.1.3.2 Third-Party Maps – An Example with PyDeck . . . . . . 305
18.2 Layout Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
18.2.1 Layout Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
18.2.1.1 Sidebar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
18.2.1.2 Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
18.2.1.3 Expander . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
18.2.1.4 Container . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
18.2.1.5 Tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
18.2.1.6 Empty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
18.3 Streamlit Cache and Session States . . . . . . . . . . . . . . . . . . . . . . . 310
18.3.1 Caching Data with @st.cache_data . . . . . . . . . . . . . . . . . 311
18.4 Storing Data with st.session_state . . . . . . . . . . . . . . . . . . . . 311
18.5 Custom HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
18.6 Multi-Page Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313

19 Building a Database Query Application 315


19.1 Building a Database Query Application . . . . . . . . . . . . . . . . . . . . 315
19.1.1 Importing the Libraries . . . . . . . . . . . . . . . . . . . . . . . . . 317
xiv Contents

19.1.2 Caching Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317


19.1.3 Creating Our App Layout . . . . . . . . . . . . . . . . . . . . . . . . 318
19.1.4 Using User Inputs to Produce a New DataFrame . . . . . . . . . . . 319
19.2 Deploying an App in the Cloud with Streamlit Share . . . . . . . . . . . . 321
19.2.1 Create a GitHub Account . . . . . . . . . . . . . . . . . . . . . . . . 321
19.2.2 Upload Application to GitHub . . . . . . . . . . . . . . . . . . . . . 321
19.2.3 Connect Streamlit Share to your GitHub . . . . . . . . . . . . . . . 322
19.2.4 Create a New App . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
19.2.5 Set Custom Subdomain . . . . . . . . . . . . . . . . . . . . . . . . . 322

V Conclusion 327
20 Conclusion 329

Index 331
Preface

I designed this textbook to serve two functions. First, it will function as a primer to Python
for humanists (or, more generally, those without coding experience or a background in
computer science). In this regard, readers will acquire a basic understanding of necessary
background information, such as data and data structures, as well as the basics of Python.
Second, this textbook is designed to not only provide the reader with a basic under-
standing of Python and how to use it, but how to apply it specifically to humanities-based
problems. The book particularly explores applying Python in data analysis with Pandas,
natural language processing (NLP) with spaCy, topic modeling with Gensim (for LDA topic
modeling) and Top2Vec (for modern topic modeling), and social network analysis with
NetworkX, Matplotlib, and PyVis. It also teaches readers how to design quick applications
with Streamlit and deploy them in the cloud with Streamlit Share.
All code throughout this textbook is designed to be as reproducible as possible. The goal
is for the reader to only need to replace the default data with their own data (or with minimal
effort get their data into a structured format) and have similar results. This should allow the
reader to begin applying the methods discussed throughout this textbook with relative ease
to their own areas of expertise.
Part I of the textbook introduces the reader to the basics of Python. Here, we will
learn about the basics of coding (Chapter 1) and the essentials about data and data
structures and how to work with them via Python (Chapter 2). These chapters will
provide the necessary foundation for exploring key programming basics, such as loops
and conditionals (Chapter 3), functions, classes, and libraries (Chapter 4), and working
with external data, such as text files and JSON (Chapter 5). The final chapter of Part I
will introduce the reader to the basics of web scraping and working with data found on
the web.
After Part I, the reader will have a basic understanding of Python, its syntax, and be able
to begin working with data to design projects. The remainder of the textbook is designed to
reinforce all of the skills acquired in Part I. Each of the following parts of the textbook will
also introduce the reader to the key libraries associated with their respective subjects.
In Part II, we will take a deep dive into data analysis. In Python, the essential library for
working with data, specifically tabular data, is Pandas. We will learn the basics of Pandas
while working with the open-source Titanic dataset. By the end of Part II, the reader will
have an understanding of Pandas and be able to leverage it in their own projects.
Part III shifts focus to text analysis. Here, we will learn about natural language process-
ing (NLP) and how to use Python and the library spaCy to engage in NLP. This part of
the textbook presumes no knowledge on the part of the reader about NLP or linguistics.
It will, therefore, provide all the basic information needed to begin working with texts in
more robust ways. The reader will learn about two different approaches to NLP, specifically
rules-based (heuristics) and machine learning-based. Both serve different functions and
should be used in different situations. By the end of this part, the reader will have a basic
understanding of each and know when to use them. While the machine learning-based
approaches will be rooted in using off-the-shelf spaCy models, the reader will learn how
to use NLP rules to create custom solutions. The final chapter of this part of the textbook

xv
xvi Preface

will look at a real-world problem, creating a rules-based heuristic pipeline to identify and
extract specific types of entities from texts.
Part IV shifts to other applications of Python to humanities-based problems. In Chap-
ter 14, we will learn how to do topic modeling, specifically Latent Dierlicht Allocation (LDA)
topic modeling so that they will have an understanding of the basic concepts and the history
of the field. After this, we will learn about more recent approaches to topic modeling using
machine learning with the library Top2Vec. Chapter 15 will look at performing text analysis
on larger documents with BookNLP. In Chapter 16, we will look at Social Network Analysis
with NetworkX and Matplotlib to produce static maps. We will also learn how to create
dynamic JavaScript and HTML network maps with the Python library PyVis. These chapters
are all designed to give you the essential background knowledge, terminology, and Python
code to get started applying these libraries and methods on your own dataset.
Part V of the textbook will introduce the reader to app development with the Streamlit
library. Readers will gain an understanding of the basics of Streamlit and how to leverage its
components to create custom apps within just a few hours that can be hosted in the cloud.
The purpose of this part is to help the reader take an idea from concept to reality in as short
of time as possible.
After completing this textbook, you will have a strong enough command of Python to
begin leveraging it in your own projects. You will also have a broad exposure to different
ways that Python can be applied to humanities-based problems. Finally, you will have the
resources necessary for continuing your education.

Limitations of This Textbook


While this book will provide a cursory overview of Python, it will not provide you with all
aspects of the language or how to use it. This book is designed to get you up and running
with Python as quickly as possible, giving you the essential tools you need to read and
write in the language to solve tasks quickly and effectively. This textbook is not designed for
computer scientists who wish to explore the depths of the programming language, rather
humanists who need Python to automate certain tasks in their workflow. Explanation of
certain aspects of the language are, therefore, kept to a minimum.
It is important to note that this book is entirely designed in Jupyter Notebooks (discussed
in Part I, Chapter 1). This means that you will not receive exposure to the command line or
receive proper training in writing a Python script (.py) file. These are useful skills
to have, but not necessary to begin working with data. Despite these limitations of the
textbook, this book will give you the tools necessary to begin learning on your own.

Online Version
The print version of this textbook also has a free online component compiled as a Jupyter-
Book. As the libraries and methods discussed in this textbook advance, the print version
of this book will not be easily updated without new editions; the online version, however,
will be updated and maintained. If a section of code quits working because something has
changed with Python or one of the libraries used in this textbook, the online version will be
Preface xvii

corrected. If you notice that there is a problem with code, you can also formally submit an
issue or suggest an edit on GitHub so that it can be updated. These can be minor issues from
typographical errors, the need for greater explanation in a specific area, or problems with
code not working. To submit a GitHub issue, you can use the GitHub icon in the top-right
corner of the online version of this book.
Acknowledgments

This Python Textbook was created during my postdoctoral fellowship at the Smithsonian
Institution’s Data Science Lab with collaboration at the United States Holocaust Memorial
Museum. It would not have been possible without the help of Rebecca Dikow, Mike Trizna,
and those in the Data Science Lab who listened to, aided, and advised me while creating
these notebooks. I would also like to thank the content experts at the United States Holocaust
Memorial Museum (USHMM), specifically Michael Haley Goldman, Michael Levy, Robert
Ehrenreich, and Silvina Fernandez-Duque.
I would also like to dedicate this book to my wife, Stephanie Mattingly. She has been a
constant source of encouragement while I wrote this book in all its stages. She also always
encouraged me to pursue data science as a career path. Without her constant guidance, this
book would not have been possible.

xix
About the Author

William Mattingly is a 2022 Harry Frank Guggenheim Distinguished Scholar and a 2022-
2023 ACLS Grantee for his work as co-principal investigator and lead developer for the
Bitter Aloe Project which examines testimonies of violence from South Africa’s Truth and
Reconciliation Commission. He is currently the Postdoctoral Fellow for the Analysis of
Historical Documents at the Smithsonian Institution’s Data Science Lab. Mattingly cur-
rently works on two projects at the Smithsonian. The first is based at the United States
Holocaust Memorial Museum (USHMM), where he is developing a robust pipeline of
machine learning image classification and natural language processing (NLP) models to
automate the cataloging of millions of images. At the Smithsonian, he is working on a proj-
ect connected to the American Women’s History Initiative. Here, he is developing machine
learning and heuristic pipelines with spaCy, a Python NLP library. This pipeline will iden-
tify women in Smithsonian documents and automatically extract knowledge about them
so that we can better understand the influential role women played at the Smithsonian.

xxi
Part I

The Basics of Python


1
Introduction to Python

1.1 Introduction to Python


1.1.1 Why Should Humanists Learn to Code?
Before we begin this book, let’s begin with a simple question. Why should humanists learn to
code? To answer it, let’s consider the ideal digital humanities project.
In an ideal digital humanities project, a humanist (or team of humanists) will leverage
their domain knowledge, or area of expertise. As a domain expert, this project leader, better
known as principal investigator (PI), will convey their idea to their team which will consist
of others in their field and usually a technical lead. This technical lead will (depending
on funding) either handle all technical aspects of the project (web development, coding,
data management, etc.) or lead a team to handle all technical aspects of it. This is the ideal
scenario. Each person on the team does what they do best.
Such a project requires two things that are in high commodity to most researchers:
funding and time. The self-reliant humanist who can leverage their domain knowledge
while also being able to function in a technical capacity on a project drastically reduces both
of these issues in several ways. To understand how, we must first understand how digital
humanities projects receive funding.

1.1.1.1 The Timeline for Starting a Large Digital History Project


Large digital projects often take years to begin. These projects often start with a researcher
(or researchers) wishing to explore a question or create a digital platform for an aspect of
their research. These scholars will then reach out to others in their field to gauge interest.
This process can take several months to a year, especially if the researchers wait to present
their idea at the next conference in their field.
If there is an interest in such a project, the project PI will find a technical expert who
can tell them if it the project is possible and receive an estimate for its cost. If the PI does
not have a technical expert and cannot find one associated with their university, this can be
challenging and time-consuming. As we will see, the relationship between PI and technical
lead is a unique bond that requires good communication from both parties. Selecting the
right technical lead is important because their pay may be one fo the larger budget items. It
is also the person who makes the PI’s vision a digital reality.
Next, the PI will create a list of funding opportunities for the project and then begin
applying to them. Each application can take several months to complete. Once complete,
the PI will then usually submit the application to the granting association through their
university. If there are multiple PIs on the project at different universities, this process can
be more complicated as all institutions usually need to communicate with each other.
The university will usually review all materials. They will be especially interested in the
budget. This process can take a few weeks while the university ensures all numbers are

DOI: 10.1201/9781003342175-2
4 Introduction to Python for Humanists

accurate. After all, most universities will be taking a cut of the grant money (sometimes up
to 30%), so they want to make sure they see the numbers first.
After this, the university will submit the grant. Depending on the granting agency, the
wait time can be anywhere from a few months to nearly a year. During this time, the digital
project will may not move forward much, if at all. Rather, it may sit in a holding period
while the PI waits to hear back.
When we look at this timeline, it means that from initial idea to the start of the project,
even in the ideal scenario, it can be realistically 2–3 years before the project begins. All of
this comes with a bit of a gamble as well. The PI believes in the idea, they have also gauged
the community to know that there is interest in it, and they have found a technical lead
who can do the job, but a lot can happen in 2–3 years. In that time, new developments in
the domain expert’s field may have altered the project trajectory (or, worst-case-scenario,
made it redundant). Further, new digital approaches/methods may mean that an entirely
new approach is necessary. This is especially common today if the project involves machine
learning, a field in which new advances are happening every week. In addition to this, the
technical lead may have taken a job elsewhere. (This does happen as they are not contracted
until the grant is received). Finally, there is no guarantee that funding agencies value the
idea. This means that the time spent designing the project conceptually and preparing to
get started could be entirely in vain.
By learning to code, you can often negate this entire process by testing your idea within
days or weeks. This means that you will be able to test the validity of the idea and potentially
even create a minimum viable product (MVP) that can be used to assist in obtaining
funding. An MVP is a working subset of a project to demonstrate its validity. For a digital
humanities project, this may mean a simple front-end application or a subset of the data
prepared a specific way. MVPs are quite common today in places such as Silicon Valley,
where MVPs are used to present an idea to investors. This helps give a real sense of how the
project will work. While not all mechanics will be available in an MVP, it is a good proof-
of-concept. It also demonstrates that the project is possible, the team can do the work they
are promising, and that the team already has a good handle of the potential issues that may
surface. These are all things that granting agencies like to see. Throughout this textbook,
you will develop the skills necessary to create an MVP that you can present to a granting
agency. This is especially true with the final chapter, where we learn how to build cloud-
based Python applications with Streamlit.

1.1.1.2 The Self-Reliant Digital Humanist


Ultimately, the ability to code turns the humanist into an entirely self-reliant researcher.
By learning to code, you can do far more than test out ideas and create MVPs. You can
significantly reduce the cost of a digital humanities project. As a domain expert, you know
your field well. As a coder, you will know what is technically possible. If you end up gaining
an expertise in data science or machine learning (something that is quite realistic today as
both fields are more accessible than ever), you can leverage some of the most powerful
methods in technical fields within a digital humanities context. You can also eliminate many
issues that may surface during a digital humanities project.
One problem is communication. The project PI needs the ability to communicate their
ideas to the technical lead. This communication often occurs in a hybrid language that
changes from team to team. The PI over time can begin to use technical terms and
the technical lead will begin to use some domain-specific terms. This relationship and
communication takes time to create. By have a strong command of the technical aspects of
a project, the PI can either eliminate the need for a technical lead entirely or communicate
their ideas to the technical side of the project in technical language.
Introduction to Python 5

Another issue that vanishes is the lag time from idea to execution. Once a funded project
begins, the PI will guide their vision and convey each step to the technical lead whose job it is
to make that vision a reality. There is a lag that exists here. Often, meetings on digital projects
occur on a regular basis, sometimes weekly or bi-weekly. During that time, issues may
surface that are placed on hold until the next meeting. This can put a digital project behind
schedule. If the humanist is self-reliant, however, they can develop their idea independently
of a technical lead. This means that when an issue surfaces, the PI can immediately rectify
it and communicate the solution to the technical lead.
Third, technical leads on projects usually absorb a lot of funding. Hiring a programmer
can be costly, but if your project requires data science and machine learning, experts in these
areas can costs hundreds of dollars per hour. If the PI has the technical expertise, they can
perform technical aspects of a project until enough money is received to hire a technical
lead.

1.1.1.3 Other Benefits


Learning to code gives the humanist tools beyond simply the ability to code. It fundamen-
tally alters how the humanist views their field and the questions they can explore. Things
that seemed impossible before, will suddenly appear quite simple to solve.
One of the greatest advantages of learning to code is automation, or the process by which
we write rules for a computer to perform a repetitive task. As humanists, we do a lot of
things repetitively. Many of the tasks we need to perform as humanists are repetitive and
we, as humans, are prone to make mistakes. Being able to automate these tasks can radically
reduce the amount of time we spend performing repetitive tasks, from hours, weeks, or even
years, to seconds, minutes, or hours. Imagine having to grab data from an archive website.
Imagine that the information you need is found on 2,000 different pages. How long would
it take you to go to each of those pages and copy and paste the text into a Word document?
In Python, that task can be coded in minutes and left to run for an hour. This allows you, the
researcher to go off and do some other task more essential; or, perhaps, enjoy a nice tea break
in a hammock so that when you return to analyze the documents, you will be well-rested.
Coding does not just allow us to automate tasks like this. It also allows us to systemat-
ically clean data. Imagine you wanted to search across PDF scans of medieval Latin. This
problem presents many key issues that make such a task impossible or unreliable. First,
medieval Latin did not have any firm spelling convention. This means that some scans may
have variant spellings of words. Second, Latin is a highly inflected language, meaning word
order is not important, rather the ending of a given word is. When combined with variant
spellings, this means that each word can be represented sometimes hundreds of different
ways. In addition to this, your texts are scans. Are those scans even searchable? If they are,
was the OCR, or Optical Character Recognition, accurate? If it was done prior to 2015, it
likely is not. If after, then the scans may be in a bad enough state where the OCR is not
accurate. In addition to these problems, any OCR system will retain line breaks, meaning
if the key word that you want to search for is hyphenated because the word is broken up
between two lines, you need to account for that in your search. Next, we need to take into
account editor notations, which often are noted in brackets, parentheses, and carrots. While
this example is certainly a complex one, it is perfectly common. And while I am using Latin
to demonstrate a greater issue with inflected languages, these same issues, especially those
around OCR, surface with English texts as well. Coding allows us to address each and every
one of these issues, some more easily than others.
The issue of searching is further complicated when this needs to be done for many
documents simultaneously. Imagine if these issues surfaced in 5,000 different PDFs that you
needed to analyze. Could you realistically run all these searches across 5,000 documents?
6 Introduction to Python for Humanists

If you could, would your results be good? To answer the former, yes, if you are willing
to spend months doing it; to answer the latter, likely not. Programming allows for you to
develop programs that perform all these tasks across all 5,000 documents. When you run a
search, you will not simply hit ctrl+f. You will code your own search method so that your
simple search can return very complex results that accounts for variance in the text.
Python makes all of this possible.

1.1.2 What Is Python?


Python is a programming language. Programming languages are ways that we, as humans,
can write commands that will then be executed by a computer. There are many different
programming languages available for humanists to choose from:

1. C
2. Python
3. JavaScript
4. R
5. HTML (this is debatable)

Not all programming languages are created equal. Some are best used for developing
software, such as C; others are best suited for web development, such as HTML and
JavaScript. And others are great at statistical analysis, R (and Python). Where does Python
excel? Python excels in many areas. One thing that sets it apart from other programming
languages for new coders is that it is easy to read and easy to write.
It is relatively easy to write compared to other programming languages because the
syntax, or way in which you write tasks in code, is straightforward. It is easy to read because
Python uses forced indentation. This means that blocks of code that can be difficult to read
in other programming languages are easily spotted in Python.
Since it’s creation in the early 1990s, Python has soared in popularity which has, in turn,
resulted in a large community of programmers and a large number of libraries available. We
will learn about libraries later in this textbook. For now, think of libraries as large quantities
of code that have already been written for you so that you can write one line of code to
perform a complex task that may take hundreds or thousands of lines of code to write.
Today, Python is one of the most widely used programming languages and is considered
the essential language for text analysis, machine learning, data analysis (alongside R), web
scrapping, and much more.
Python (as of this writing) is currently in version 3.11.0. Let’s break each of these
numbers down. The 3 refers to the main Python language. Python 2 still exists (in fact it
comes standard on all Macs), but it is no longer supported and is slowly being replaced
by Python 3. You should not invest time in learning Python 2 as it is only used to
support legacy software and has a high number of security issues due to its depreciated
status. This is important to note because certain things are coded differently between the
two programming languages. If you were to look for help on a coding forum, such as
StackOverflow, it is important to know about these distinctions.
The 11.0 in Python 3.11.0, tells us specifically what version of Python 3. Not all code
from certain libraries is backwards compatible, meaning some libraries require a specific
version of Python, so understanding this now as a concept will save confusion later. Each
time a new version comes out, new features are available, so it is important to stay up-to-
date with current versions, but it is not always essential.
Introduction to Python 7

1.1.3 Why Python?


For all the above reasons, I encourage humanists to learn Python as their first programming
language. It is one of the easiest languages to learn, straightforward to write, and can solve
most of the programmatic problems a humanist may face. The large quantities of libraries
and tutorials mean that there are few tasks that will prove impossible to do.
If you are sold on Python, then continue reading this textbook as we learn how to install
it and use it as humanists.

1.2 Installing Python


The most challenging thing about working with Python (or any programming language) is
learning how to install it correctly. Why is this such a challenge? Because installing Python
differs dramatically by operating system and version of operating system. I present to
you five different ways you can start programming Python from the easiest to the more
challenging.
1. Using the Trinket applications embedded throughout the digital version of the
textbook
2. Using Google Colab for each each individual section of the textbook
3. Using the free built-in Binder feature of this textbook
4. Using a free online Jupyter Notebook
5. Installing Python locally via Anaconda Navigator and using JupyterLab
If you are entirely new to programming, I recommend ignoring options 2–4 and simply
using option 1 during the first part of this textbook. In my experience, it is important early
in your programming journey to have as few roadblocks as possible. If you are interested in
jumping in with Python as quickly as possible, then use the freely available Trinket widgets
in the online version of this textbook and return to the installation of Python at a later time.

1.2.1 Trinket
Throughout the digital version of the textbook, you will see Trinket applications embedded
within each page. Trinket allows you to practice your coding skills without ever installing
Python. If you are new to coding and want to get started immediately without installing
Python, I recommend working with Trinket inside the digital version of this textbook.
These will allow for you to practice the lesson right inside the digital textbook.
You will be able to write your code inside this Trinket application and then click the
play button at the top. This will execute your code and populate the results on the right
hand output.

1.2.2 Using Google Colab


During the first part of the textbook, nearly all code can be executed with Trinket. Even
the section on Pandas can be done inside of Trinket. However, the later sections will be
8 Introduction to Python for Humanists

increasingly difficult as they require libraries that are not supported by Trinket. At this time,
you will want to consider another option. Again, to delay the installation of Pyonn on your
machine, we can rely on other cloud-based alternatives.
There are two options for running this textbook’s code in the cloud outside of the
textbook: Google Colab and Binder (addressed below). In the top right corner of each page
is a rocket ship. If you hold your mouse of this rocket ship, you will have two options to
choose from, Binder or Colab. Click Colab.

FIGURE 1.1
Picture of Rocket Ship in Top-Right Corner of Online JupyterBook.

Once you click the Colab button you will be taken to Google Colab and see a Notebook
inside the Google Colab system that should look like this:

FIGURE 1.2
Demo of Google Colab Opened.
Introduction to Python 9

Once here, you can run the notebook.


Colab and Binder have their advantages. Google Colab will be far quicker but will
require you to install the requisite libraries for each page. For most of the first part of the
textbook, this will not be necessary as we will not be working with libraries. You will learn
how to install libraries locally and in a Jupyter Notebook (such as those used on Google
Colab) later in this part of the textbook. Once the libraries are installed, the entire notebook
can be run as if you were running the notebook locally. A downside to Google Colab is its
inability to leverage the data found within this textbook. This means that in some cases,
you will need to manually upload the data into Google Colab for some notebooks to run as
expected.
Another benefit of Google Colab is that it is connected to your Google account. This
means any changes that you make to the notebook can be saved onto your Google Drive
and used at a later date. Each time you open the notebook, however, a unique instance of
Python is created which means you will need to reinstall your libraries. Fortunately, this
process is quite quick.

1.2.3 Using Binder from JupyterBook


Another cloud-based solution is with Binder. Unlike Google Colab, Binder will load up an
environment for the entire textbook and install all libraries using the requirements.txt
file found in this textbook’s repository on GitHub. This means that Binder will take
substantially longer to load, but will contain the entire textbook. It will save the instance
for a period of time as well so that if you return to the same link in a short period of
time, there is a chance it will not have to reinstall all the libraries again. In my experience,
Binder can run into some issues that can be difficult to diagnose, especially if you are new
to programming. For this reason, I would recommend Google Colab over Binder to new
programmers.
As with Google Colab, to begin, put your mouse over the rocket ship icon in the top-right
portion of the page.

FIGURE 1.3
Demonstration of Rocket Ship in Top-Right Corner.
10 Introduction to Python for Humanists

A button should emerge that says “Binder”. Click it.

FIGURE 1.4
Selecting the Binder Button.

At this stage, your screen should look like should look like this:
If it does, then sit back and relax. It may take a few minutes as Binder builds the
environment. Once Binder is finished, click on “File” in the top left corner of the screen
and then select “New Notebook”.

FIGURE 1.5
Creating a New Notebook in Binder.

After this, select “Python 3 (ipykernal)”. This will open a fresh, new notebook.

FIGURE 1.6
Selecting the Python 3 Kernal for the New Notebook.
Introduction to Python 11

Now you should have a new notebook that looks like this:

FIGURE 1.7
Example of a New Notebook Page.

And now, you can fully follow along with this textbook.

1.2.4 Using Jupyter Notebooks Online


If you want to be a bit more independent and learn how to code in Python online without
Binder and this textbook, you can! You do not need to download and install Python on your
local computer either. Instead, you can use free online compilers that allow you follow along
with nearly all of this textbook without issue.
If this is your view at the moment, then click this link: https://jupyter.org/try
Once on the page click the picture that says Jupyter Notebook.

FIGURE 1.8
Creating a Jupyter Notebook Online.
12 Introduction to Python for Humanists

After that, you will see a screen that looks like this:

FIGURE 1.9
Binder Creating a New Environment for the Notebook.

After a few minutes, the environment will load and you should see a notebook. Click
“File” in the top left corner, New Notebook, and select Python (Pyodide).

FIGURE 1.10
Creating a New Notebook.
Introduction to Python 13

Once loaded, you can follow along with this textbook in the new notebook.

FIGURE 1.11
Example of a New Notebook.

1.2.5 Installing Python Locally


If you wish to install Python locally and it is your first time, there are many problems that
can surface. For this reason, I am now recommending all students install via Anaconda
Navigator. It adds extra steps into the installation process, but it eliminates the potential for
mistakes to occur.
Anaconda Navigator is a user-friendly interface that handles the installation process for
you. It also allows for you to create environments, which are small areas on your computer
that have a unique version of Python and libraries installed. We will learn more about this
in Part I, Chapter 4 when we explore libraries.
In this chapter, I will walk you through the steps of installing Anaconda Navigator on
your machine, regardless of operating system.
When we write code in Python, we do so a few different ways, depending on that code’s
use. Because this is a textbook and the code I am writing is for presentation purposes, I am
using a Jupyter Notebook. Other times, you may write a program in an IDE, or an Integrated
Development Environment. Some of these include PyCharm, VS Code, etc. In other cases,
you will use Python in the terminal to perform quick tasks on data in a directory.
Anaconda Navigator removes the need for you to learn how to do all of this because
it allows for you to easily install JupyterLab which functions like an IDE but is a bit more
forgiving. In addition, you can call terminal sessions. I know these terms do not make sense
right now, but as your understanding of programming expands, this paragraph will make
14 Introduction to Python for Humanists

FIGURE 1.12
Anaconda’s Homepage.

more sense. For now, simply understand that Anaconda Navigator and JupyterLab (both of
which we install in this chapter), make your start to learning to code much, much simpler.

1.2.5.1 Download Anaconda Navigator


Now, click on the “Download” button as seen in Figure 1.13 and walk through the
installation process on your computer. Once complete, you will have Anaconda Navigator
installed.

1.2.5.2 Using Anaconda Navigator


Now that Anaconda Navigator is installed, you can use it by opening it up on your
computer. When you first see Anaconda Navigator, you will see several options on the left.
In environments, you will only see one environment: base. Don’t worry about environments
this early in your Python career. For now, we will simply click the “Home” button on the
left.

1.2.5.3 Installing JupyterLab


In order to start using Python, there are a few different options available to you. You could
use a terminal and follow along with the textbook, but that can be quite difficult if you are
just starting out. Since this textbook was designed in JupyterLab, I think it makes the most
sense to install that software. Go ahead and click “Install” under JupyterLab. Once installed,
you will be able to “Launch” it and follow along with the textbook.
Introduction to Python 15

FIGURE 1.13
Download Individual Edition.

FIGURE 1.14
The Anaconda Navigator Main User Interface.

1.2.6 Conclusion
If at any point in the installation process you get frustrated, do not get discouraged. You are
not alone and it is not a simple or easy process. Those who have been programming for years
can make these steps look simple, but troubleshooting issues on your own is challenging.
16 Introduction to Python for Humanists

FIGURE 1.15
How to Install Jupyter Lab.

It is important to remember that programming in general is challenging. Try to view the


challenges that surface as a fun problems that need solving. Try to look at your mistakes
through a lens of Bob Ross and view them as happy accidents.

1.3 Coding Basics


Before we jump into the textbook, we should cover a few basic aspects of programming
that the reader may not know. These are some of the most essential terms and concepts that
you will see used throughout this textbook. Remember, you can always come back to this
section if you forget one of these terms.

1.3.1 The Print Function


The very first thing that every programmer learns is how to print something off using the
relevant programming language. In most tutorials, you will see the phrase “Hello, World!”
used. In this textbook, let’s try something a bit different. Let’s say I wanted to print off
“Hello, William”. We can do this in Python by using the print function. The print function
lets us print off some piece of data. In our case, that piece of data will be a piece of text,
known as a string (see below). Our text is “Hello, William⣞. The thing that we want to
print off must be located between an open parentheses and a close parentheses. Let’s try to
execute the print command in the cell below.
print("Hello, William!")

Hello, William!
Introduction to Python 17

As we can see, the code that we typed in the Jupyter cell outputted beneath it. Now, it
is your turn. Try to print off something. In order to print off text, you will need to use an
open and a close quotation mark. We will learn more about this as we meet strings in the
next chapter.

<IPython.lib.display.IFrame at 0x7f0a6c7b3af0>

This has worked wonderfully, but what if our Python notebook needs to be more
dynamic, meaning it needs to adjust based on some user input. Perhaps, we need to use
a name other than William based on some user-defined input. To do this, we would need
to store a piece of data in memory. We can do this in Python by creating a variable that will
point to an object. Before we get into how this is done, let’s first get to know objects and
variables.

1.3.2 Objects
When we import or create data within Python, we are essentially creating an object in
memory with a variable. These two words, object and variable mean slightly different
things, but are often used interchangeably. We will not get into the complexities of their
differences and why they exist in this textbook, but for now, view an object as something
that is created by a Python script and stored in your computer’s memory so that it can be
used later in a program.
Think of your computer’s memory rather like your own brain. Imagine if you needed to
remember what the word for “hello” is in German. You may use your memory rather like
a flashcard, where “hello” in English equates to “hallo” in German. In Python, we create
objects in a similar way. The object would be the dictionary entry of “hello: hallo”.

1.3.3 Variables
In order to reference this dictionary entry in memory, we need a way to reference it. We do
this with a variable. The variable is simply the name of the item in our script that will point
to that object in memory. Variables make it so that we can have an easy-to-remember name
to reference, call, and change that object in memory.
Variables can be created by typing a unique word, followed by an “=” sign, followed by
the specific data. As we will learn throughout this chapter, there are many types of data that
are created differently. Let’s create our first object before we begin. This will be a string, or
a piece of text. (We will learn about these in more detail below.) In my case, I want to create
the object author. I want author to be associated with my name in memory. In the cell, or
block of code, below, let’s do this.

author = "William Mattingly"

Excellent! We have created our first object. Now, it is time to use that object. Below, we
will learn about ways we can manipulate strings, but for now, let’s simply see if that object
exists in memory. We can do this with the print function.
The print function will become your best friend in Python. It is, perhaps, the function I
use most commonly. The reason for this is because the print function allows for you to easily
debug, or identify problems and fix them, within your code. It allows us to print off objects
that are stored in memory.
To use the print function, we type the word print followed by an open parentheses. After
the open parentheses, we place the object or that or piece of data that we want to print. After
18 Introduction to Python for Humanists

that, we close the function with the close parentheses. Let’s try to print off our new object
author to make sure it is in memory.
print(author)

William Mattingly

Notice that when I execute the cell above, I see an output that relates to the object we
created above. What would happen if I tried to print off that object, but I used a capital letter,
rather than a lowercase one at the beginning, so Author, rather than author?

1.3.4 Case Sensitivity

print(Author)

---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 print (Author)

NameError: name 'Author' is not defined

The scary looking block of text above indicates that we have produced an error in Python.
This mistake teaches us two things. First, Python is case sensitive. This means that if any
object (or string) will need to be matched in not only letters, but also the case of those letters.
Second, this mistake teaches us that we can only call objects that have been created and
stored in memory.
Now that we have the variable pointing to a specific piece of data, we can make our print
function above a bit more dynamic. Let’s try and print off the same statement as before, but
with the new full author name. I don’t expect you to understand the specifics of the code
below, rather simply understand that we will frequently need to store variables in memory
so that we can use them later in our programs.
print(f"Hello, {author}!")

Hello, William Mattingly!

1.3.5 Reserved Words


When working with Python, there are a number of words known as reserve words. These
are words that cannot be used as variable names. As of Python version 3.6, there are a total
of 33 reserve words. It can sometimes be difficult to remember all of these reserve words, so
Python has a nice built in function, “help”. If we execute the following command, we will
see an entire list.
help("keywords")

Here is a list of the Python keywords. Enter any keyword to get more help.

False class from or


None continue global pass
True def if raise
(continues on next page)
Introduction to Python 19

(continued from previous page)


and del import return
as elif in try
assert else is while
async except lambda with
await finally nonlocal yield
break for not

These are words that you cannot use as a variable name.

1.3.6 Built-in Types


In addition to reserve words, there are also built-in types in Python. These are words that
you can use (as we will see) to convert one type of data into another. There are 94 of these
in total. Unlike reserve words, you can use a built-in type as a variable name. It is, however,
strongly discouraged to do so because it will overwrite the intended use of these variable
names in your script.
import builtins
[getattr(builtins, d) for d in dir(builtins) if isinstance(getattr(builtins, d), type)]

[ArithmeticError,
AssertionError,
AttributeError,
BaseException,
BlockingIOError,
BrokenPipeError,
BufferError,
BytesWarning,
ChildProcessError,
ConnectionAbortedError,
ConnectionError,
ConnectionRefusedError,
ConnectionResetError,
DeprecationWarning,
EOFError,
OSError,
Exception,
FileExistsError,
FileNotFoundError,
FloatingPointError,
FutureWarning,
GeneratorExit,
OSError,
ImportError,
ImportWarning,
IndentationError,
IndexError,
InterruptedError,
IsADirectoryError,
KeyError,
KeyboardInterrupt,
LookupError,
MemoryError,
ModuleNotFoundError,
NameError,
(continues on next page)
20 Introduction to Python for Humanists

(continued from previous page)


NotADirectoryError,
NotImplementedError,
OSError,
OverflowError,
PendingDeprecationWarning,
PermissionError,
ProcessLookupError,
RecursionError,
ReferenceError,
ResourceWarning,
RuntimeError,
RuntimeWarning,
StopAsyncIteration,
StopIteration,
SyntaxError,
SyntaxWarning,
SystemError,
SystemExit,
TabError,
TimeoutError,
TypeError,
UnboundLocalError,
UnicodeDecodeError,
UnicodeEncodeError,
UnicodeError,
UnicodeTranslateError,
UnicodeWarning,
UserWarning,
ValueError,
Warning,
OSError,
ZeroDivisionError,
_frozen_importlib.BuiltinImporter,
bool,
bytearray,
bytes,
classmethod,
complex,
dict,
enumerate,
filter,
float,
frozenset,
int,
list,
map,
memoryview,
object,
property,
range,
reversed,
set,
slice,
staticmethod,
str,
(continues on next page)
Introduction to Python 21

(continued from previous page)


super,
tuple,
type,
zip]

Of this long list, I recommend paying particular attention to the ones that you are more
likely to write naturally: bool, dict, float, int, list, map, object, property, range, reversed, set,
slice, str, super, tuple, type, and zip. You are more likely to use these as variable names by
accident than, say, ZeroDivisionError; and this shorter list is a lot easier to memorize.

1.3.7 Type Function


It is frequently necessary to check to see what type of data a variable is. To identify this, you
can use the built-in function type in Python. To use type, we use the command below with
the data we want to analyze placed between the two parentheses.
type("this is a string...")

str

1.3.8 Bugs
Throughout your programming career, you will often read or hear about bugs. A bug is
a problem in your code that either returns an error or an unintended result in the output.
Tracing down bugs and fixing them is known as debugging. Aside from figuring out how
to code solutions to problems, debugging can be one of the more time-consuming aspects
of writing a program, especially if it is quite complex. Throughout this textbook, we will
encounter common errors so that you can see them in this controlled space. We will also
walk through what the error means and how to resolve it. That said, you are likely to create
many other bugs as you try to apply the code in this textbook to your own data. That is
expected. Always remember to read each line of your Pyhon carefully and, if you have an
error message, identify where the error is coming from and what it is.
2
Data and Data Structures

In this chapter, we will be learning about data and data structures. As with any program-
ming language, it is important to have a basic understanding in these two concepts as
they are the building blocks for most things you will do in Python. Whenever you write
a program or do something with code, you are essentially writing commands to load, save,
interact with, and manipulate data in some way. Understanding the different types of data
and how to structure and store them is, therefore, essential.

2.1 Introduction to Data


2.1.1 What Is Data?
In Python there are seven key pieces of data and data structures which we will be working
with:

• Strings (text)
• Integers (whole numbers)
• Floats (decimal numbers)

• Booleans (True or False)


• lists
• tuples (lists that cannot be changed in memory)
• dictionaries (key : value)
In this chapter, we will explore each of these. While this section focuses on data: strings,
integers, floats, and Booleans; the next section will focus on data structures: lists, tuples, and
dictionaries.
Data are pieces of information (the singular is datum) i.e., integers, floats, and strings.
Data structures are objects that make data relational, i.e., lists, tuples, and dictionaries. Start
to train your brain to recognize the Python syntax for these pieces of data and data structures
discussed below.
For your convenience, here is a cheatsheet for helping you refer back to these types of
data.

DOI: 10.1201/9781003342175-3
24 Introduction to Python for Humanists

Cheatsheet for Data Types and Data Structures in Python


Name Type Category Example Trick Mutable
string str text "William" quotes no
integer int number 1 no decimal no
float float number 1.1 with decimal no
Boolean bool boolean True True or False no
list list sequence [1, 1.1, "one"] [] yes
tuple tuple sequence (1, 1.1, "one") () no
set set sequence {1, 1.1, "one"} {} - unique yes
dictionary dict mapping {"name": "tom"} {key:value} yes

2.1.2 Strings
Strings are a sequence of characters. A good way to think about a string is as text. We can
create a string in python by designating a unique variable name and setting = to something
within quotation marks, i.e., " " or "".
The opening of a quotation mark indicates to Python that a string has begun and the
closing of the same style of a quotation mark indicates the close of a string. It is important
to use the same style of quotation mark for a string, either a double or a single.
Let’s take a look at a few examples of strings.

Examples of Strings
In our first example of a string, we will name our first string object with the variable name
first_string. Notice that we are using an underscore (_) to indicate a separation of two
words in our variable name. This is common practice in Python. We cannot use a space in a
variable name. Another naming convention could be firstString, where the first word is
lower cased while the start of each sequential word is capitalized. This naming convention,
while acceptable, is more common in other programming languages, such as JavaScript.
first_string = "This is a string."

Now that we have created our first object, let’s try and print it off. We can do this using
the print function.
print(first_string)

This is a string.

Let’s take a look at another example. This time, however, we will use two ’.
second_string = 'This is a string too.'
print(second_string)

This is a string too.


Data and Data Structures 25

Let’s now take a look at a bad example of a string. In the example below, we will
intentionally try to create an error message by combining two different types of quotation
marks.

bad_string = "This is a bad example of a string'

Input In [6]
bad_string = "This is a bad example of a string'
ˆ
SyntaxError: EOL while scanning string literal

This error message tells us that we have triggered a “SyntaxError”. A SyntaxError is a


Python error in which we have used improper syntax, or coding language. This means that
when our computer tries to execute the above code, it does not know how to interpret the
line. You will frequently encounter errors like this in your journey as a programmer.
It is always important to read the error message as it will inform you about the specifics
of the problem. For example, I can see that my error was triggered because of something in
the input cell 6. If you were executing this same command within a Python script, you would
see the specific line that triggered the error. This allows you to begin to debug or identify
the source of the error and fix it. If, for some reason, you cannot understand the cause of the
error, it may help to Google the error message and search for answers on forums, such as
StackOverflow.
Sometimes, it will be necessary to have a very long string that spans multiple lines within
a Python script. In these instances, you can use three of the same quotation mark style (single
or double) consistently to create a string over multiple lines.

long_string = '''

This is a verrry long string.

'''

print(long_string)

This is a verrry long string.

2.1.3 Working with Strings as Data


Often when working within Python, you will not be simply creating data, you will
be manipulating it and changing it. Because humanists frequently work with strings, I
recommend spending a good deal of time practicing and memorizing the basic ways we
work with strings in Python via the built-in methods.
In order to interact with strings as pieces of data, we use methods and functions. The
chief functions for interacting with strings on a basic level come standard with Python. This
means that you do not need to install third-party libraries. Later in this textbook we will do
more advanced things with strings using third-party libraries, such as Regex, but for now,
we will simply work with the basic methods.
Let’s learn to manipulate strings now through code, but first we need to create a string.
Let’s call it sentence.

sentence = "I am going to learn how to program in Python!"


26 Introduction to Python for Humanists

2.1.3.1 Upper Method


It is not a very clever name, but it will work for our purposes. Now, let’s try to convert the
entire string into all uppercase letters. We can do this with the method .upper(). Notice
that the .upper() is coming after the string and within the () are no arguments. This is a
way you can easily identify a method (as opposed to a function). We will learn more about
these distinctions in the chapters on functions and classes.
print(sentence.upper())

I AM GOING TO LEARN HOW TO PROGRAM IN PYTHON!

2.1.3.2 Lower Method


Noice that our string is now all uppercase. We can do the same thing with the .lower()
method, but this method will make everything in the string lowercase.
print(sentence.lower())

i am going to learn how to program in python!

2.1.3.3 Capitalize Method


On the surface, these methods may appear to only be useful in niche circumstances. While
these methods are useful for making strings look the way you want them to look, they have
far greater utility. Imagine if you wanted to search for a name, “William”, in a string. What
if the data you are examining is from emails, text messages, etc. William may be capitalized
or not. This means that you would have to run two searches for William across a string. If,
however, you lowercase the string before you search, you can simply search for “william”
and you will find all hits. This is one of the things that happens on the back-end of most
search engines to ensure that your search is not strictly case-sensitive. In Python, however,
it is important to do this step of data cleaning before running searches over strings.
Let’s explore another method, .capitalize(). This method will allow you to capital-
ize a string.
first_name = "william"

print(first_name.capitalize())

William

I will use this in niche circumstances, particularly when I am performing data cleaning
and need to ensure that all names or proper nouns in a dataset are cleaned and well-
structured.

2.1.3.4 Replace Method


Perhaps the most useful string method is .replace(). Notice in the cells below, replace
takes a mandatory of two arguments, or things passed between the parentheses. Each is
separated by a comma. The first argument is the substring or piece of the string that you
want to replace and the second argument is what you want to replace it with. Why is this so
useful? If you are using Python to analyze texts, those texts will, I promise, never be well-
cleaned. They may have bad encoding, characters that will throw off searches, bad OCR,
Data and Data Structures 27

multiple line breaks, hyphenated characters, the list goes on. The .replace() method
allows you to quickly and effectively clean textual data so that it can be standardized.
Unlike the above methods, for .replace(), we need to put two things within the
parentheses. These are known as arguments. This method requires two and they must be
in order. The first is the thing that you want to replace and the second is the thing that you
want to replace it with. These will be separated by a parentheses and both must be strings.
It should, therefore, look something like this:
.replace("the thing to replace", "the thing you want to replace it with")

In the example below, let’s try and replace the period at the end of “Mattingly.”

introduction = "My name is William Mattingly."

print(introduction.replace(".", ""))

My name is William Mattingly

Excellent! Now, let’s try and reprint off introduction_sentence and see what
happens.

print(introduction)

My name is William Mattingly.

Uh oh! Something is not right. Nothing has changed! Indeed, this is because strings are
immutable objects. Immutable objects are objects that cannot be changed in memory. As we
will see in the next chapter with lists, the other type of object is one that can be changed
in memory. These are known as mutable objects. In order to change a string, therefore,
you must recreate it in memory or create a new string object from it. Let’s try and do that
below.

new_introduction = introduction.replace(".", "")

print(new_introduction)

My name is William Mattingly

2.1.3.5 Split Method


Strings have a lot of other useful methods that we will be learning about throughout this
textbook, such as the split() method which returns a list of substrings, or smaller strings,
that are split by the delimiter, which is the argument of the method. The delimiter tells
Python how to split the string. By default, split() will split your string at the whitespace.
Let’s try and split the following string.

book_name = "Harry Potter and the Chamber of Secrets"

As with replace, split() is a method and, therefore, we use it with a “.” after the
variable name.

print(book_name.split())
Random documents with unrelated
content Scribd suggests to you:
95, 104.
Héliodore chassé du temple, tableau de Delacroix (chapelle des
Saints-Anges, à Saint-Sulpice), I, 411 note 479; II, 467; III, 350.
—Esquisse du même, III, 401.
Héliodore chassé du temple, tableau de Francesco Solimena, I, 203
note 208.
HENNEQUIN (Amédée), ami de Berryer, II, 353 et note 4, 358, 362,
363, 366, 368.
HENRI IV, II, 485.
Henri IV dans sa maison. petite toile de Delacroix, I, 311.
Henri IV, drame de Shakespeare, III, 424.
Héraclius, tragédie de Calderon, III, 320, 321
HERBAUT, I, 344, 372.
HERBELIN (Mme), peintre, II, 89 et note 1, 137, 157, 175;
III, 35, 130 et note 5, 132, 162, 184 et note 1, 396.
Hercule étouffant Antée, toile de Delacroix, II, 314 et note 3.
Hercule ramène Alceste du fond des enfers, tympan décoratif
de l'Hôtel de ville, par Delacroix, I, 216.
Hercule et Diomède, toile de Delacroix, II, 286 et note 4.
HERMANT (Adolphe), dit Hermann, violoniste, II, 314 et note 2.
Herminie et les bergers, toile de Delacroix, II, 291;
III, 143, 161 et note 1, 162, 362 note.
Hérodote interroge les traditions des Mages, peinture décorative,
de la bibliothèque du Palais-Bourbon, par Delacroix, I, 257.
Hésiode et la Muse, peinture décorative de la bibliothèque
du Palais-Bourbon, par Delacroix, I, 257.
HESSE (Nicolas-Auguste), peintre, III, 416.
HETZEL, libraire et littérateur, II, 269 et note 2.
HIPPOCRATE, II, 367; III, 177.
Hippocrate refuse les présents du roi de Perse, peinture décorative
de la bibliothèque du Palais-Bourbon, par Delacroix, I, 258.
HIS (Charles), publiciste, I, 271 et note 287.—(Mme), II, 342 et
note.
Histoire de la Révolution, par Michelet, I, 302.
Histoire de la vie et des ouvrages de Raphaël, par Quatremère
de Quincy, I, 108 et note 127.
Histoire de l'Égypte sous Méhémet-Ali, par Maugin, I, 108.
Histoire de ma vie, par George Sand, III, 34 et note 2.
HITTORF (Jacques-Ignace), architecte, III, 63 et note 4, 304.
HOGARTH (William), peintre et graveur anglais, III, 38, 41.
HOMÈRE, II, 72, 258, 260, 301, 302, 388; III, 240, 263, 272,
310, 348, 361.
Homme dévoré par un lion, toile de Delacroix, I, 351 et note 409,
357.
Hommes couchés, après le bain, I, 215.
Hommes jouant aux échecs, toile de Delacroix, I, 357.
HORACE, I, 75 note 87; III, 171, 254, 361.
Hortensias, toile de Delacroix, I, 347, 354.
HOUDETOT (le comte D'), administrateur et homme politique,
I, 137 et note 155; II, 313.
HOUSSAYE (Arsène), littérateur, II, 290 et note 1.
HUBER (Pierre), naturaliste suisse, III, 57 et note.
HUET (Paul), peintre paysagiste, II, 377 et note 1; III, 118
et notes 1 et 3, 323.
HUGO (Victor), liii, liv, I, 210 et note 215, 363, 371; II, 201, 302.
Huguenots (les), opéra de Meyerbeer, I, 268; II, 300, 301.
HUGUES (Henri), cousin de Delacroix, I, 9 note 11, 13, 19, 25, 58,
63, 71, 97, 255.
HUNT (William-Holmant), peintre anglais, III, 38 et note 3, 51.

IDEVILLE (comte D'), diplomate, II, 369; III, 118.


Iliade (l'), III, 263, 270, 348.
INGRES, peintre, xlix, li, lii; I, 84 et note 104, 87, 139, 195, 345,
366; II, 161, 286, 317 et note, 352 et note 2, 375 et note 3;
III, 22, 27, 36, 42, 88, 113, 147, 335, 416.
Intérieur d'Oran (Un), toile de Delacroix, I, 314.
Intérieur de harem, toile de Delacroix, II, 292.
Intérieur d'un potier en Italie, esquisse de Decamps, II, 175.
Iphigénie en Aulide, tragédie lyrique de Glück, I, 422.
È
IRÈNE, amie de Delacroix, II, 151.
ISABEY (J.-B.), peintre miniaturiste, I, 416 et note 485, 432; II, 310,
445, 448, 449, 455; III, 239.—(Mme et Mlle), II, 445.
Italiana in Algieri (l'), opéra-bouffe de Rossini, III, 318.
Ivanhoé, roman de Walter Scott, III, 421.
Ivanhoé, tableau de Delacroix, I, 46.
Ivanhoé et Rebecca, petite toile de Delacroix, III, 348.

JACOB (Henri), lithographe, I, 72.


JACOB, cousin de Delacroix, I, 72; II, 349; III, 112 et note.
JACQUAND, peintre, I, 333 et note 389.
JACQUET, marchand de curiosités, I, 306 et note 351.
JACQUINOT (le général Charles), cousin de Delacroix, I, 53, 56.
JADIN, paysagiste, I, 271 et note 286.
JALABERT, peintre, II, 227 et note 2; III, 165.
JAN (Laurent), journaliste, I, 243 et note 241, 256, 257, 316; III, 42,
43, 44.
Jane Eyre, roman de Charlotte Bronte, III, 351 et note 1.
Jane Shore, aquarelle, lithographie et peinture de Delacroix, I, 74,
79, 92, 93, 95, 104.
JANIN (Jules), critique, II, 105 et note 1; III, 42, 43.
JANMOT (Louis, dit Jan-Louis), peintre, III, 41 et note 1, 88.
Jardin de Méquinez, aquarelle de Delacroix, I, 214.
JAUBERT (Mme), écrivain, I, 423 et note 490; II, 123 note, 355 note
2,
359 note 2; III, 54, 56, 57, 397.
JENNY. Voir LE GUILLOU.
Jérusalem délivrée (la), poème du Tasse, I, 375; II, 291 et note 4;
III, 29 note, 385.
Jésus flagellé, toile de Rubens, musée d'Anvers, II, 6.
Jésus qui veut foudroyer le monde, toile de Rubens, musée
d'Anvers, II, 5.
Jeune femme qui se peigne, toile de Delacroix, II, 306 et note.
Jeune fille dans le cimetière, toile de Delacroix, III, 53 et note.
Jeune homme qui déjeune, petite toile de Meissonier, II, 220.
Jeune marin expirant, sculpture par Allier, I, 98.
Job et ses amis, tableau de Decamps, II, 165, 174.
JOLY DE FLEURY, magistrat, III, 122.
JOLY GRANGEDOR, peintre, élève de Delacroix, II, 87 note 1.
JOMINI (baron), général et écrivain suisse, II, 292.
JORDAENS, maître flamand, I, 303; III, 282.
Joseph, opéra de Méhul, I, 96.
Joseph Balsamo, roman d'Alexandre Dumas père, II, 115, 117,
123, 433; III, 342 note 1.
Joséphine (l'Impératrice), portrait par Prud'hon, I, 301 et note 340.
Josué arrêtant le soleil, aquarelle de Decamps, II, 165 et note.
JOUAUT, III, 71.
JOURNÉ (Mme), fille de M. Bornot, I, 403 note 71.
JOUVENET (J.), peintre, II, 173.
Jugement de Paris (le), toile de Raphaël, I, 283.
Jugement dernier (le), toile de Chenavard, II, 470.
Juif errant (le), opéra d'Halévy, II, 96 et note 1.
Juifs de Méquinez, toile de Delacroix, I, 214, 311.
Juive (la), opéra d'Halévy, III, 141 et note 2
Juives de Méquinez, toile de Delacroix, I, 214.
Juives de Tanger, toile de Delacroix, I, 214.
Jules César, tragédie de Shakespeare, III, 321.
JULES ROMAIN, maître italien, III, 39.
JULIE, servante de Delacroix, II, 330, 438; III, 31.
Juliette sur le lit, tableau de Delacroix, I, 214.
JUSSIEU (Joseph DE), botaniste, I, 344, 447 note 503.
—(Adrien), son fils, I, 447 et note 504.
Justinien, toile de Delacroix, II, 387 note 1.

Kaïd goûtant le lait que lui offrent les paysans, dessin à la plume,
de Delacroix, I, 214.
KALERJI (Mme), amie de Chopin, I, 359, 369, 371, 372, 431;
III, 86, 90, 91, 92.
KANT, philosophe allemand, II, 443.
KARR (Alphonse), littérateur, II, 213 et note.
KAYSER (DE), peintre, II, 411.
KERDREL (M. DE), homme politique, II, 488.
KIATKOWSKI, ami de Chopin, II, 223.
KLOTZ, architecte de Strasbourg, III, 83.
KNEPFLER, peintre, I, 278.
Knox le puritain prêchant devant Marie Stuart, esquisse de Wilkie, I,
196 note.

LABBÉ, I, 247.
LABLACHE (Mlle Mariette), cantatrice, II, 176 et note 3.
Labourage nivernais, toile de Rosa Bonheur, musée du Luxembourg,
I, 351 note 410.
LA BRUYÈRE, II, 182; III, 352.
Lac (le), poésie de Lamartine, I, 366.
LACÉPÈDE (DE), naturaliste, I, 239.
LA COMBE (le colonel DE), auteur d'un ouvrage sur Charlet,
III, 187 note 2, 371 note 2.
LACROIX (Gaspard-Jean), peintre paysagiste, I, 288 et note 320,
289,
291, 307 et note 352.
Lady Macbeth, toile de Delacroix, I, 377 et note 450.
LAFONT (Émile), peintre, I, 431 et note 497.
LA FONTAINE, II, 51, 216, 390, 396, 440; III, 171.
LAGNIER, III, 166.
LAGUERRE (le docteur), III, 276, 277, 284, 288, 290, 291, 304,
318, 433 et note 2.
LAITY, ancien lieutenant d'artillerie, II, 314 et note 1; III, 118.
LAJUDIE (Mme DE), fille aînée du baron Rivet, III, 65 et note, 404.
LAMARTINE, I, 87, 91, 346, 367, 415; II, 347 et note, 348, 396;
III, 110, 348, 397.
LAMBERT (Eugène), peintre, II, 87 et note 1.
LAMBERT (Mme), fille de M. Bornot, I, 403 note 471.
LAMEY, cousin de Delacroix, I, 75 note 86; III, 81 et note, 82, 93,
96,
132, 163 et note 5, 161, 165, 277, 278, 289, 294, 335, 336,
413, 416.—(Mme), I, 105; III, 83, 85, 86, 96, 132.
LAMEY (Ferdinand), III, 85.—(Mme), III, 148.
LAMORICIÈRE (le général), I, 447 et note 503; II, 364.
LAMY (Eugène), peintre et dessinateur, II, 174 et note.
LANDON (Paul), peintre et littérateur, II, 401 et note.
LANGLOIS (Jean-Charles), peintre, III, 324 et note 2.
LANTON, III, 86.
LAPORTE (M DE), consul de France au Maroc, I, 150 et note 168.—
(Mme), I, 394.
LARCHEZ, I, 105.
LARIBE, I, 30.
LA RIVE, tragédien, I, 272.
LARIVIÈRE,peintre, II, 311 et note 2.
LARREY (le baron), chirurgien, I, 286 et note 316.
LAS MARISMAS (Mme), III, 297.
LASSALLE (Émile), peintre, élève de Delacroix, I, 274 et note 297,
290;
II, 87 note 1; III, 174 et note 3.
LASSALLE-BORDES, peintre, élève de Delacroix, I, 260 note 267,
261;
III, 167 note.
LASSUS (J.-B.-Antoine), architecte, I, 343 et note 399; II, 177.
LASTEYBIE (le comte DE), archéologue, II, 152 et note 2.
LATOUCHE (Henri DE), littérateur, III, 34 et note 3.
LATOUR (Maurice-Quentin DE), pastelliste, III, 169 et note 3.
LAUGIER (Jean-Nicolas), graveur, I, 130 et note 144.
LAUGIER (Stanislas), chirurgien, I, 306 et note 349.
LAURE, modèle, I, 92, 93, 104, 130, 131.
LAURENCEAU(Baron), ami de Berryer, II, 487, 490.—(Baronne), II,
487.
LAURENS (Joseph-Bonaventure), littérateur et compositeur, I, 326 et
note 383.
LAURENS (Jules), peintre, lithographe et graveur, I, 326 et note 383,
424 et note 491; II, 37.
LAVALETTE (le comte DE), III, 45 note, 46, 173.—(Mme DE), II,
391;
III, 45 et note.
LAVOYPIERRE, cuisinier, II, 483.
LAWRENCE, peintre anglais, II, 162 et note 1; III, 36 note, 38, 69,
216, 377.
LEBLOND (Frédéric), ami de Delacroix, I, xiii; I, 43 et note 49, 53,
72, 66, 69, 71, 72, 74 à 76, 82, 90, 91, 94, 96, 102, 103, 107,
117, 124, 127, 129, 130, 132, 135 à 139, 247, 281, 290, 307,
308, 317, 318, 354, 369.—(Mme), I, 282, 308, 354.
LEBORNE (Joseph-Louis), peintre, I, 92.
LEBOUC (Charles), violoncelliste, III, 131 et note 2.
LÈBRE, archéologue, III, 363.
LEBRUN (Charles), peintre, I, 368; II, 91, 173, 315; III, 119, 248,
252, 291.
LECOMTE (Hippolyte), peintre, II, 76 et note 1.
LECZINSKI (Stanislas Ier), roi de Pologne, III, 278, 279,
280, 281, 283.
Léda, fresque de Delacroix, à Valmont, I, 193 et note 196.
LEDRU (Hilaire), peintre, III, 395 et note 3.
LEDRU DES ESSARTS (le général), voisin de campagne de Delacroix,
à Champrosay, I, 445 et note 499.
LEDRU-ROLLIN, homme politique, II, 376.
LEFEBVRE, marchand de tableaux, I, 357 et note 418.
LEFEBVRE (Charles), peintre, I, 290 et note 322; II, 292.
LEFEBVRE (Jules), peintre, III, 289 et note.
LEFÈVRE-DEUMIER, littérateur et poète, II, 314 et note 6, 386;
III, 120 et note 1.—(Mme), sculpteur, II, 314 et note 6; III, 120.
LEFRANC, marchand de couleurs, I, 316; II, 411.
LEFUEL, architecte, II, 229 et note 2; III, 10, 26, 135.
LEGENDRE, III, 410.
Législation (la), peinture décorative de la bibliothèque
du Palais-Bourbon, par Delacroix, I, 257.
LEGOUVÉ (E.), auteur dramatique, III, 20.
LEGRAND, ami de Berryer, III, 292.
LEGRAND (Mme Pierre), fille de M. Bornot, I, 403 note 471.
LEGROS (Pierre), sculpteur, II, 129 et note 2.
LE GUILLOU (Jenny), gouvernante de Delacroix, I, 256 note 257,
315 et note 365,
383, 406, 434, 442, 444; II, 1, 15, 25, 103 et note, 123,
134, 185, 186, 202, 210, 228, 842, 247 et note 1, 256, 169,
286, 328 à 331, 333, 336, 380, 387, 411, 417, 425, 427, 430,
438, 447, 477, 492; III, 24, 29, 93, 101, 103, 104 et note.
105, 107, 108, 132, 145, 101, 179, 180, 266, 269, 272, 278,
284. 288, 304, 347, 409, 433 et note.
LEHMANN, peintre, II, 81 et note 1, 89, 106, 295.
LEHON (Mme), II, 378.
LEHON fils, II, 378,
LEIBNITZ, philosophe allemand, II, 442.
LELEUX (Adolphe-Pierre), peintre, I, 235 et note 229, 253, 302.
Lélia, toile de Delacroix, I, 324, 332 et note 387.
LELIÈVRE, peintre, I, 46, 53, 56, 57, 75, 84, 99, 105, 106.
—Mme, I, 54, 55, 92.
LEMAITRE (Frederick), acteur, II, 201 et note.
LEMERCIER (Népomucène), littérateur, I, 81, note 96.
LEMOINNE (John), journaliste, III, 108 et note 1.
LEMOLE (M.), amateur, I, 93.
LENOBLE, homme d'affaires de Delacroix, I, 297, 328, 335.
LENORMANT (Charles), archéologue et historien, III, 344 et note 1.
LÉON X (le pape), II, 377.
Léonore, opéra de Beethoven, appelé aussi Fidelio,
I, 297 et note 334, 417.
LÉOTAUD (Mme DE), III, 5.
LEQUIEN fils, dessinateur, III, 68.
LERMINIER, publiciste, I, 317.
LEROUX (Eugène), lithographe, III, 164 et note 1.
LEROUX (Jean-Marie), graveur et dessinateur, III, 160 et note 2.
LEROUX (Pierre), publiciste, I, 325 et note 382; III, 2 note 3.
LEROY (F.), III, 150.
LEROY D'ETIOLES, chirurgien, III, 350.
LESAGE, peintre, II, 396.
LESAGE, romancier, III, 360.
LESLIE (Charles-Robert), peintre anglais, III, 37 et note 1.
LESPINASSE (Mlle DE), femme de lettres, III, 428.
LESSERT (Mme DE), III, 331.
LESSORE (Émile-Aubert), paysagiste, I, 311 et note 360, 335.
LESUEUR, peintre, I, 203, 300, 304; II, 63, 64, 91, 129, 171; III,
253.
Lettre sur les spectacles, de J.-J. Rousseau, II, 407.
Lettres sur l'Egypte, par Savary, I, 107 et note 125.
—Sur la Grèce, I, 107, note 125.
LEVASSOR, acteur comique, II, 419 et note 2; III, 21 et note 1.
LEVEL, sculpteur, II, 495.
LEYGUE, peintre, élève de Delacroix, II, 87 note 1.
LEYS (Henri), peintre belge, II, 30 et note; III, 39.
LEWIS, romancier anglais, I, 213 et note 216.
LHÉRITIER (le docteur), III, 345 et note 1.
Liberté de 1830 (la), toile de Delacroix, musée du Louvre, I, 337.
Lion (le), gravure de Denon, I, 296.
Lion (un), tableau de Delacroix, I, 234 note 226.
Lion (un), pastel de Delacroix, I, 239.
Lion(le petit), tableau de Delacroix, II, 418
Lion dans les montagnes, toile de Delacroix, II, 61.
Lion guettant sa proie, tableau de Delacroix, II, 292 et note.
Lion (un), toile de Van Thulden, à Bruxelles, II, 8.
Lion et le Sanglier (le), toile de Delacroix, II, 137.
Lion et l'Homme mort (le), toile de Delacroix, I, 291, 293, 301.
Lion terrassant un sanglier, toile de Delacroix, II, 138.
Lions, deux toiles de Delacroix, II, 340 et note 1; III, 137, 143.
Lions (deux), toile de Delacroix, II, 138.
LISETTE, paysanne du Louroux, I, 2, 4, 5, 6, 14.
LISZT, pianiste et compositeur allemand, I, 288 note 319; II, 47; III,
68 et note 1.
Loges du Vatican (les), I, 79 note 92.
LONCHAMPS (Pierre-Charpentier DE), littérateur, III, 392 et note 1.
LOPEZ ou LOPÈS, peintre, I, 27 note 36, 45, 53, 72, 75, 104.
LORD-MAIRE de Londres (le), III, 30, 31.
Loth, toile de Rubens, musée du Louvre, II, 388.
Louis XIV, III, 5.
Louis XVI, II, 350, 376.
LOUIS-PHILIPPE, I, 79 et note 93, 171.
Louroux (le), propriété du général Charles Delacroix, en Touraine, I,
1.
Louvois, III, 5.
LUCAS DE LEYDE, maître hollandais, I, 386; II, 4 et note; III, 226.
LUCCA DELLA ROBBIA, sculpteur florentin, II, 437.
Lucrèce et Tarquin, toile de Titien, I, 273.
Lucrezia Borgia, opéra de Donizetti, II, 281 et note 2, 293, 302.
LULLI, musicien et compositeur, III, 13.
Lumière du monde (la), toile de Hunt, III, 38 note 3.
LUNA (Ch. DE), peintre, II, 94.
Lutte de Jacob avec l'ange (la), peinture décorative de la chapelle
des Saints-Anges, à Saint-Sulpice, par Delacroix, I, 411 note 479.
Lycurgue consulte la Pythie, peinture décorative de la bibliothèque
du Palais-Bourbon, par Delacroix, I, 257 note 260, 261 note 267;
II, 92.
LYONNE (M. DE), I, 272.

Macbeth, tableau de Fielding, I, 116.


Macbeth, traduction en vers de J. Lacroix, III, 434 et note 2.
MACHIAVEL, II, 445.
Madeleine dans le désert (la), toile de Delacroix, I, 279.
Madeleine en prière, toile de Delacroix, II, 274 et note.
MAGE, I, 71, 73.
MAGENDIE (François), physiologiste, III, 327, 328, 329 et note 1.
MAGNE, homme d'État, III, 413.
MAINDRON (Hippolyte), sculpteur, I, 296 et note 332.
MAISON (le maréchal), II, 478.
Maître Pathelin, opéra-comique de Fr. Bazin, III, 185 et note 3.
Maîtres d'autrefois (les), ouvrage d'Eug. Fromentin, II, 5 note 1,
7 note, 24 note.
Maîtres et petits maîtres, ouvrage de Ph. Burty, I, 420 note 487.
MALHERBE, III, 388.
MALIBRAN (la), cantatrice, I, 247, 248, 249, 250.
MALLEVILLE, I, 346.
MANCEY (M.), II, 176.—(Mme), II, 176.
MANCEAU (M.), membre du Conseil municipal de Paris, II, 78, 87,
147, 464.—(Mme), II, 147, 454, 456, 462; III, 409.
MARBOUTY (Mme), ou Claire Brunne, écrivain, III, 344 et note 3,
351.
MARC-ANTOINE RAIMONDI, graveur italien, II, 273 et note 2; III,
226.
Marc-Aurèle mourant, toile de Delacroix, musée de Lyon, I, 274,
351 et note 411; III, 30 note.
MARC-AURÈLE, empereur romain, III, 30, 100.
MARCELLINI CZARTORYSKA (la princesse), I, 408 et note 476, 414;
II, 163, 169, 222, 224, 285, 309, 358 et note, 360, 362, 365, 494,
496;
III, 2 et note 1, 8, 11, 12, 120, 122, 126, 127, 131, 139, 156.
MARCHAND (le comte), III, 120 et note 2.
Marchand d'oranges, toile de Delacroix, II, 138.
Marché aux chevaux (le), toile de Rosa Bonheur, II, 226 note 1.
Marché d'Arabes (le), aquarelle de Delacroix, I, 214.
Marcus Sextus, tableau de Guérin, I, 44.
Mare au Diable (la), roman de George Sand, I, 302.
Maréchal marocain, toile de Delacroix, II, 137.
MARESTE (le baron DE), I, 272 et note 292, 358; III, 50, 124, 182.
MARET, duc de Bassano, II, 486 et note.
Marguerite auprès de l'autel, lithographie originale de Delacroix,
III, 131 et note 1.
Marguerite en prison, lithographie de Delacroix, III, 292.
MARGUERITTE, III, 267.
Mariage mystique de sainte Catherine, toile de Rubens, à Anvers, II,
6.
Mariage secret (le) (Il matrimonio segreto),
opéra bouffe de Cimarosa, I, 277, 293 et note 328, 419.
Marianne, tragédie de Voltaire, III, 319.
MARIE, modèle, I, 25, 133.
MARIE-LOUISE (l'impératrice), II, 374.
Marie Stuart, opéra de Niedermeyer, I, 249.
Marino Faliero, toile de Delacroix, II, 222 note 4; III, 143 et note 4.
MARIO, chanteur italien, II, 282, 327.
MARIVAUX, II, 272.
MARLIANI (la comtesse), amie de Chopin, I, 252 et note 246, 305,
310,
325, 326, 345, 406; II, 243.
Maroc (voyage au), cahier de notes et de croquis de Delacroix,
appartenant autrefois à M. le professeur Charcot, qui l'a légué à la
bibliothèque du Louvre, I, 145.
Marocain à cheval, toile de Delacroix, III, 143.
Marocain montant à cheval, toile de Delacroix, II, 476, 479.
Marocains (les deux), toile de Delacroix, II, 229.
Marocains endormis, tableau de Delacroix, I, 255, 291.
MAROCUETTI, sculpteur, I, 97 et note 119, 104, 108.
Marquise de Pescara (portrait de la), I, 75 et note 85.
MARRAST (Armand), homme politique, I, 344 note 402.
MARS (Mlle), tragédienne, I, 268, 290 et note 321, 291.
MARTIGNAC (vicomte DE), homme politique, II, 359.
MARTIN (Jean-Blaise), chanteur, II, 402 et note 2.
MARTIN-DELESTRE, peintre, I, 305.
MARTINET (Achille-Louis), graveur, III, 268 note 1.
MARTINET (Louis), peintre, III, 26 et note 5.
Martyre de saint Cyr et de sainte Juliette (le),
toile de Heim, église Saint-Gervais, III, 83 note 1.
Martyre de saint Pierre (le), toile de Rubens, à Cologne, II, 167.
Massacre de Scio (le), tableau de Delacroix, I, 37, 39 note 45, 85
note 106,
107, 123, 125, 132, 235 note 228; II, 222 note 4, 281 note, 353
et note 1,
381 et note 2.
Massacre des Innocents (le), de Raphaël, gravure, I, 96.
MASSILLON, III, 293.
MASSON (Adolphe), aquafortiste, III, 350 et note 2.
MASSON (Alphonse), graveur, I, 235 et note 228.
Mater dolorosa, esquisse de Delacroix, I, 325.
MATHILDE (la princesse), II, 179 et note 3.
Mauprat, drame tiré du roman de George Sand, II, 283 et note.
MAUZAISSE (J.-B.), peintre et lithographe, I, 27 note 37; II, 28.
MAXIME DU CAMP, littérateur et critique, I, viii.
MAYER, peintre, I, 134 et note 147.
Mazeppa, croquis et dessin de Delacroix, I, 73, 86.
Médée, toiles diverses de Delacroix, I, 70, 274 note 297, 324;
II, 222 note 4.
Mêlée furieuse, toile de Delacroix, III, 157 et note, 165,
174 note 3, 308.
Méditations poétiques (les), de Lamartine, I, 415.
MEER (Van der), maître hollandais, III, 211.
MÉHUL, compositeur, I, 96.
MEISSONIER, peintre, I, 350 et note 408, 351, 408, 414, 417; II,
220, 435;
III, 36, 118, 121, 220 note, 416.
Mélanges d'histoire et de philosophie, par Voltaire, III, 413.
Melmoth ou l'Amende honorable, toile de Delacroix, I, 81.
MEMBRÉE (Edmond), compositeur, III, 3 et note 2, 4.
Mémoire sur la peinture, I, 59 et note 66.
Mémoires de Dumas, II, 280, note 2.
Mémoires d'Horace, par A. Dumas père, III, 412.
Mémoires d'un bourgeois de Paris, du docteur Véron, II, 225 note 1,
247 note 2, 258.
MÉNARD (la), danseuse, III, 62.
MÉNARD (Louis), critique d'art, I, 311 et note 362.
MÉNARD (René), peintre, I, 311 note 362.
MENDELSSOHN, I, 294, 326; II, 83, 327; III, 12, 389.
MÉNESSIER (Mme), I, 346, 363.
MENEVAL (le baron DE), I, 379 et note 455, 380, 432; II, 224.
MENEVAL (Mme), III, 351.
MENGS (Raphaël), peintre et écrivain allemand, III, 193 et note,
248, 384.
MENJAUD, acteur, I, 74 et note 83.
Menuet (le), dessin de Charlet, III, 427. Voir CHARLET.
MERCEY (Frédéric Bourgeois DE), peintre et écrivain, I, 358 et note
419;
II, 38, 295, 313, 379; III, 63 et note 2, 64, 117, 331, 336, 337,
434.
MÉRIMÉE (Prosper), littérateur et romancier, I, 346; II, 179 et note
1,
221, 264, 317; III, 4, 26, 64, 125, 179, 180, 276 note.
MERRUAU (Charles), journaliste, III, 132 et note 2.
MESNARD (Jacques-André), homme politique, III, 127 et note 1,
128, 184.
Métamorphoses (les) d'Ovide, III, 332.
Meunier d'Angibault (le), roman de George Sand, I, 222 et note 218.
MEYERBEER, I, xliv, 346, 371, 372; II, 282, 293, 297, 299, 300, 301;
III, 9.
MÉZY (DE), I, 372.
MICHAUD (Joseph), dit Michaud aîné, littérateur, et non Michaud
jeune
comme il est dit, II, 361 et note 1, 362.
MICHEL (le baron), médecin militaire, III, 146 et note 2.
MICHEL-ANGE, I, xx, xxxiii, I, 2, 44, 50, 51, 83, 87, 98, 111, 142,
181, 196, 202, 203, 227, 299, 407, 410, 414; II, 28, 29, 92,
136, 160, 2, 185, 188 et note, 95, 428, 429, 435, 440, 469,
470, 471, 477, 478, 496; III, 15, 64, 70, 96, 156, 195, 197, 234,
238 et note, 255, 256, 257, 261, 264, 265, 309, 311, 252, 356,
357, 358, 364, 365, 369, 382, 394, 430.
Michel-Ange dans son atelier, toile de Delacroix, musée de
Montpellier,
I, 384, 444, 446; II, 138; III, 352.
MICHELET, historien, I, 302, 317.
MICKIEWICZ (Adam), poète polonais, II, 53 et note.
MIERIS (Franz VAN), maître hollandais, III, 211.
MILLAIS (John Everin), peintre anglais, III, 38 notes 2 et 3, 39 et
note 1.
Mille et une Nuits (les), III, 419.
MILLET, peintre, II, 160 et note 2, 161.
Milton soigné par ses filles, tableau de Delacroix, I, 25.
MINORET, voisin de campagne de Delacroix, à Champrosay, I, 445;
II, 185, 212, 265; III, 334.
MIRABEAU, II, 472, 473.
Mirabeau répondant au marquis de Dreux-Brézé, toile de Delacroix,
II, 472 et note; III, 351 et note 3;
—toile de Chenavard, II, 472 et note, 473.
MIRBEL (Mme DE), peintre en miniature, I, 383 et note 456; III,
405.
MIRÈS, financier, II, 312 et note 3, 313.
Mirrha, tragédie d'Alfieri, III, 49 et note 2, 61.
Misanthrope (le), I, 74 note 83; II, 433; III, 270.
MITHRIDATE, I, 402.
MOCQUART, littérateur et homme politique, II, 76 et note 2, 77;
III, 339, 342.
MOHL (Jules), orientaliste, III, 131 note 3.—(Mme), III, 131 et note
3.
Moine (le), roman de Lewis, I, 213 note 216.
Moïse, statue de Michel-Ange, II, 496.
Moïse frappant le rocher, toile de Delacroix, II, 309.
Moïse, opéra de Rossini, I, 69, 70, 137.
MOLÉ, (le comte), homme politique, I, 344, 360.
MOLIÈRE, I, 301, 315, 428; II, 412, 433, 440; III, 13, 96, 332, 370
note 1,
374, 389, 397, 398.
Moniteur (le), II, 158 et note 2, 386, 410, 406; III, 40, 134,
237, 240, 263.
MONTAIGNE, I, iv, 227, 439; II, 441; III, 224, 362.
MONNIER (Henry), littérateur et comédien, III, 408.
MONTEBELLO (le comte DE), III, 46.
Monte-Cristo (le comte de), roman d'Alexandre Dumas père,
I, 259, 277, 285, 287.
Montée au Calvaire (la), toile de Rubens, musée de Bruxelles,
II, 5 et note 2.
MONTESQUIEU, I, 390, 391, 395 et note 467, 402, 403; II, 134; III,
427.
MONTFORT (Antoine-Alphonse), peintre, III, 180 et note 2.
MONTIJO (Mme DE), III, 347.
MONTPENSIER (le duc DE), I, 270 note 285, 281.
Monument d'Eugène Delacroix au jardin du Luxembourg, III, 303.
MOORE (Morris), amateur anglais, III, 306 note 2, 331.
MOREAU (M.), collectionneur, I, 269 et note 281, 288; II, 155 note,
291 note 3, 296, 330 et note 2; III, 26, 28, 31 et note 2, 51,
101, 135 et note 2, 330.
MOREAU (Gustave), peintre, III, 174 et note 2.
MOREAU-NÉLATON (Adolphe) fils, collectionneur, II, 330 note 2.
MORNAY (Charles, comte DE), diplomate, ami de Delacroix, I, 22,
145 note 161, 146 note 163, 148 à 151 note 169, 164, 268 et
note 280, 296,
302, 311, 323, 325, 340, 347, 409.
MORNY (duc DE), homme politique, I, 295; II, 75 et note 2, 378;
III, 4, 51, 137.
Mort de saint Jean-Baptiste (la), peinture décorative de la
bibliothèque
du Palais-Bourbon, par Delacroix, I, 257; II, 90 note 1.
Mort de Pline l'Ancien (la), peinture décorative de la bibliothèque
du Palais-Bourbon, par Delacroix, I, 258.
Mort de Sardanapale, toile de Delacroix, I, 209 et note 213.
Mort de Sélim (la), projet de tableau de Delacroix, d'après
lord Byron, II, 115.
Mort de Valentin, tableau de Delacroix, I, 239 et note 231, 252,
287, 288, 291.
MOTTEZ (Victor-Louis), peintre, I, 367 et note 431.
MOUILLERON (Adolphe), lithographe, III, 26 et note 3, 124, 131.
Mousquetaires (les Trois), d'Alex. Dumas père, I, 311.
MOUTIÉ (Mme), III, 415.
Moutons égarés, toile de Munt, III, 38 note 3, 51.
MOZART, I, xliv, 21, 55, 230, 266, 268, 270, 274, 275, 283, 294,
297, 308, 317, 352, 360, 365, 368, 371, 409, 413, 414, 418,
419, 422, 426: II, 82, 160, 166, 167, 169, 187, 190, 222, 223,
260, 261, 285, 286, 289, 309, 319, 323, 325, 328, 352, 440;
III, 2, 12, 13, 59, 70, 139, 186, 225, 234, 311, 353, 355.
Muley-Abd-el-Rhaman, tableau de Delacroix, I, 206 et note 211.
MÜLLER (Louis), peintre, I, 254 et note 250, 255.
MURILLO, maître espagnol, I, xxxviii, 144, 187, 190, 229; II, 286;
III, 231, 350.
Musiciens juifs de Mogador, tableau de Delacroix, I, 175 et note 182,
310.
MUSSET (Alfred DE), II, 90 et note 2.
MUSSET (Paul DE), III, 275 et note 2, 297.
MUSTAPHA, II, 76 et note 3.

Nabuchodonosor, opéra de Verdi, I, 293 et note 328.


NADAILLAC (Mme DE), amie de Berryer, III, 331.
NADAUD (Gustave), chansonnier, II, 312 et note 1, 374; III, 397 et
note.
NALDI (Giuseppe), chanteur italien, I, 249, et note 244.—(Mme), I,
249.
—(Mlle), cantatrice, I, 249 note 244.
Nanon de Lartigues, roman d'Alex. Dumas père, III, 15.
NANTEUIL (Célestin), graveur, III, 326 et note 1.
NAPOLÉON Ier, I, 113, 115, 236, 379 et note 455, 380;
II, 31, 75, 224, 276, 374, 376, 486, 487, 496;
III, 4, 7 et note 3, 111, 354, 355, 364.
NAPOLÉON III, I, 345, 426; II, 306, 313, 393, 403; III, 46, 66,
268, 339, 341 et note, 342.
NAPOLÉON (le prince Jérôme), II, 147; III, 25, 27, 330.
Napoléon au tribunal d'Alexandre et de César, par Jomini, II, 292.
NASSAU, modèle de Delacroix, I, 65, 66.
NASSAU (le duc DE), II, 16.
Naufrage, toile de Delacroix, II, 292, 306.
Naufrage de la Méduse (le), tableau de Géricault, musée du Louvre,
I, 22 note 31, 46 note 54, 78, 88 note 108, 136 note 152; II, 92
note 1, 251.
NAVEZ (François-Joseph), peintre belge, II, 3 et note 3.
NÈGRE (Charles), photographe, III, 403 et note 1.
Nègre de Tombouctou (le), aquarelle de Delacroix, I, 215.
NELSON (l'amiral), II, 168.
NEMOURS (le duc DE), I, 273.
Neveu de Rameau (le), de Diderot, I, 260 et note 266.
NEY (le maréchal), I, 379; II, 359 note 1.
NIEDERMEYER, compositeur suisse, I, 367.
NIEL (M.), bibliothécaire au ministère de l'intérieur, I, 260 et note
265.
NIEUWERKERKE (le comte DE), directeur général des Musées, II,
179 et note 2;
III, 21, 25, 26 98, 99.
Nina, ou la Folle par amour, opéra de Coppola, II, 351 et note.
NISARD (M.), littérateur et critique, II, 295 et note 2.
Noce juive au Maroc (la), tableau de Delacroix, 1, 154 et note 174.
NODIER (Charles), littérateur, bibliothécaire de l'Arsenal, II, 80 et
note 2.
Norma (la), opéra de Bellini, II, 293, 487.
NOURRIT (Adolphe), chanteur, II, 235 note 1; III, 131 note 2, 305
et note 1.
Nouvelles russes, de Nicolas Gogol, II, 264 et note 1.
Nozze di Figaro, opéra de Mozart, I, 21, 25; II, 488; III, 139.
Numa et Égérie, peinture décorative de la bibliothèque du
Palais-Bourbon, par Delacroix, I, 257, note 260.
Nymphe endormie, toile de Delacroix, I, 331 et note 386.
Nymphes de la mer (les) détellent les chevaux du Soleil,
projet de tableau de Delacroix, pour la galerie d'Apollon, et non
exécuté, I, 336.

Obermann, de Pivert de Senancour, I, 206, 207; III, 205, 234,


237, 268 et note 2.
Obéron opéra de Weber, II, 82 et note.
Odalisque, diverses toiles de Delacroix, I, 291, 357, 358;
II, 479, 481.
OÈBÈNE ou ŒBEN (Victoire), mère d'Eugène Delacroix, I, vii; 7 note
7;
III, 302 note 1.
Olinde et Sophronie, toile de Delacroix, II, 291 et note 4, 330,
335, 336 et note 2, 340; III, 29 note, 143.
ONSLOW (Georges), compositeur, I, 283 et note 311, 354.
Ophélia dans le ruisseau, toile de Delacroix, II, 138.
Orange (l'), gravure de Debucourt, I, 186.
Ordre d'élargissement (l'), toile de Millais, III, 38, 39 note 1.
O'REILLY (Mme), II, 80.
ORLÉANS (la duchesse D'), I, 273.
Orphée, de Glück, III, 391 et note 2, 409.
Orphée apportant la civilisation à la Grèce, peinture décorative
de la bibliothèque du Palais-Bourbon, par Delacroix, I, 257, 262
note 269,
265 et note 274, 280, 285, 287 note 319, 289.
ORSEL (Victor), peintre, I, 367 et note 432.
OSSUNA (le duc D'), I, 360.
Othello, tragédie de Shakespeare, III, 424.
Othello toile de Delacroix, I, 284, 291 et note 324.
Othello, opéra de Rossini, I, 293 et note 328; III, 52.
OTTIN, sculpteur, II, 375 et notes 2 et 3.
OTWAY (Thomas), poète anglais, I, 70 et note 77.
OUDRY (Jean-Baptiste), peintre animalier, II, 162 et note 2; III, 203.
OUVRIÉ (Justin), peintre et lithographe, III, 49 et note 3
Ovide chez les barbares, peinture décorative de la bibliothèque
du Palais-Bourbon, par Delacroix, I, 257; II, 92.
Ovide exilé chez les Scythes, toile de Delacroix, II, 291 et note 3;
III, 135 note 2, 137, 143 et note 5, 161 note, 182, 362 note.

Pacha de Laroche (le), croquis de Delacroix, I, 214.


PAËR (Ferdinand), compositeur et pianiste, I, 114 et note 134; III,
276 note.
PAGANINI, violoniste, III, 126.
PAÏVA (la comtesse DE), III, 9, 20.
Paix consolant les hommes (la) et ramenant l'abondance,
peinture décorative du salon de la Paix, à l'Hôtel de ville,
par Delacroix, II, 134 note.
Paix mettant le feu à des armes (la), esquisse de Delacroix d'après
Rubens, I, 329.
Palatiano (portrait du comte), par Delacroix, I, 253; II, 405 et note.
Panhypocrisiade, poème satirique de Népomucène Lemercier, I, 81
note 96, 83.
PANSERON, compositeur, II, 311 et note 3; III, 130 et note 4, 181 et
note 2.
PAPETY, peintre, II, 447 et note.
PAPPLETON, I, 84.
PARCHAPPE (le général), voisin de campagne de Delacroix à
Champrosay,
II, 197 note 1, 237 et note 2; III, 36, 44, 161, 178 et note 1, 331,
334, 348.—(Mme), II, 197 note 1; III, 33, 52, 334, 335.
PARISET (Étienne), médecin et littérateur, II, 367 et note; III, 176,
177.
PARODI (Mme), cantatrice, II, 293.
PASCAL (Blaise), II, 190, 446, 453 note; III, 189, 390.
PASCOT (Charles), oncle de Delacroix, I, 19 note 28, 27.
PASQUIER (le duc), homme politique, III, 362.
Passion (la petite), suite de gravures sur bois d'Albert Dürer, I, 375.
PASTA (Mme), cantatrice, I, 26, 71, 248, 250; II, 293.
PASTORET (le marquis DE), littérateur, III, 63 et note 1, 67, 132 et
note 3.
PASTRÉ, II, 478.
PATIN (Gui), II, 177; III, 20.
PATIN (Henri-Joseph-Guillaume), professeur et littérateur, III, 20.
PENGUILLY L'HARIDON (Octave), peintre, I, 271 et note 289; III,
181 et note 1.
PAYEN (Anselme), chimiste, III, 4 et note.
Paysage avec Grecs, toile de Delacroix, III, 182 et note 4.
Paysage de Tanger, au bord de la mer, toile de Delacroix,
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like