Chapter 17. Data Discovery and Visualization
Preview
Although FastAPI does have API in its name, it can serve more things than APIs. This chapter shows you how to generate tables, plots, graphs, and maps from data, using a small database of imaginary creatures from around the world.
Python and Data
Python has become very popular in the last few years for many reasons:
-
Ease of learning
-
Clean syntax
-
Rich standard library
-
Huge number of high-quality third-party packages
-
Special emphasis on data manipulation, conversion, and introspection
The last point has always been relevant for traditional ETL tasks for database creation. A nonprofit group called PyData even organizes conferences and develops tools for open source data analysis with Python. The popularity of Python also reflects the recent surge in AI and the need for tools to prepare the data that feeds AI models.
In this chapter, we’ll try some Python data packages and see how they relate to modern Python web development and FastAPI.
PSV Text Output
In this section, we’ll use the creatures listed in Appendix B.
The data is in this book’s GitHub repo,
in
the pipe-separated file cryptid.psv
and the SQLite database cryptid.db.
Comma-separated (.csv)
and tab-separated (.tsv) files are common,
but commas are used within the data cells themselves,
and tabs are sometimes hard to distinguish
from other whitespace.
The pipe character (|
) is distinct,
and rare enough in standard
text to serve as a good separator.
Let’s ...
Get FastAPI now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.