Jupyter prelude

Author

Dheepak Krishnamurthy

Published

December 16, 2024

Keywords

python, ibis, pandas, matplotlib, jupyter

uv

# This will create a new Python environment in the current directory
uv init --app

# This will add the specified packages to the environment
uv add "ibis-framework[duckdb,geospatial]" ipykernel panel hvplot holoviews matplotlib pandas param lonboard folium

prelude

################################################################################

# autoreload all modules every time before executing the Python code
%reload_ext autoreload
%autoreload 2

################################################################################

from IPython.core.interactiveshell import InteractiveShell

# `ast_node_interactivity` is a setting that determines how the return value of the last line in a cell is displayed
# with `last_expr_or_assign`, the return value of the last expression is displayed unless it is assigned to a variable
InteractiveShell.ast_node_interactivity = "last_expr_or_assign"

################################################################################

import pandas as pd

# `copy_on_write` is a performance improvement
# This will be the default in a future version of pandas
# Refer to https://pandas.pydata.org/pandas-docs/stable/user_guide/copy_on_write.html
pd.options.mode.copy_on_write = True

################################################################################

%matplotlib inline

import matplotlib as mpl

# `constrained_layout` helps avoid overlapping elements
# Refer to https://matplotlib.org/stable/tutorials/intermediate/constrainedlayout_guide.html
mpl.pyplot.rcParams['figure.constrained_layout.use'] = True

Reuse

Citation

BibTeX citation:
@online{krishnamurthy2024,
  author = {Krishnamurthy, Dheepak},
  title = {Jupyter Prelude},
  date = {2024-12-16},
  url = {https://kdheepak.com/blog/jupyter-prelude/},
  langid = {en}
}
For attribution, please cite this work as:
D. Krishnamurthy, “Jupyter prelude,” Dec. 16, 2024. https://kdheepak.com/blog/jupyter-prelude/.