Skip to content

Commit

Permalink
fix(bugs): a few broken links
Browse files Browse the repository at this point in the history
  • Loading branch information
lwasser committed Oct 4, 2024
1 parent 4289e5b commit 8a06484
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions clean-modular-code/activity-2/clean-code-part-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ combined_papers_df = pd.concat([papers_df_1, papers_df_2], axis=0)
combined_papers_df.shape
```

+++ {"editable": true, "slideshow": {"slide_type": ""}}

## On your own 1

If you get through the above activity with time to spare, here are a few additional tasks that you can work on.
Expand Down
14 changes: 8 additions & 6 deletions clean-modular-code/pep8-package-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ kernelspec:
name: python3
---

+++ {"editable": true, "slideshow": {"slide_type": ""}}

# Best Practices for Importing Python Packages In Scientific Code

There are a set of best practices that you should follow when importing **Python** packages in your code. These best practices are outlined in the <a href="https://www.python.org/dev/peps/pep-0008/#imports" target="_blank">PEP 8 guidelines</a> and apply to both **Python** scripts and to working in **Jupyter Notebook** files.
Expand All @@ -21,12 +23,12 @@ It is good practice to import all of the packages that you will need at the top

This allows anyone looking at your code to immediately know what packages they need to have installed in order to successfully run the code. This rule also follows the PEP 8 conventions for **Python** code.

<figure>
<a href="/images/jupyter/import-packages-first-cell.png">
<img src="/images/jupyter/import-packages-first-cell.png" alt= "Jupyter Notebook with the first code cell importing the numpy package (and many others) to be used with abbreviations or aliases (e.g. np)."></a>
<figcaption> Jupyter Notebook with the first code cell importing the numpy package (and many others) to be used with abbreviations or aliases (e.g. np for numpy).
</figcaption>
</figure>
```python
import os

import pandas as pd
import numpy as np
```

Once you have imported all of the packages that you need to run your code in a script, you have access to all of the functions and classes defined in each package.

Expand Down

0 comments on commit 8a06484

Please sign in to comment.