This section provides a series of examples demonstrating how to call Stata from within Python by using the magic commands and API functions defined in the pystata Python package. For more details on their usage, you can go to Magic commands and API functions.

The following examples were run within a Jupyter Notebook.