How to Run a Cell in Jupyter Notebook Only If a Value Is Null?

22 Replies, 1809 Views

Hey there! I’ve been using `IPython` magic commands to handle this kind of thing. You can use `%run` to conditionally run cells based on a value.

```python
if some_value is None:
%run next_cell.py
```

Just save the code you want to run in another file and call it like this. It’s a bit of a workaround, but it keeps your notebook cleaner.

Also, [this Stack Overflow thread](https://stackoverflow.com/questions/tagg...r-notebook) has some great tips on jupyter notebook run a cell if a value is null.

Messages In This Thread



Users browsing this thread: 3 Guest(s)