How to setup bamboolib on Amazon SageMaker

Installation for Jupyter Notebook (see below for JupyterLab)

1. Go to the Amazon SageMaker UI

2. Create a Lifecycle Configuration

Go to NotebookCreate lifecycle configuration and create a lifecycle configuration called install-bamboolib. Copy paste the script below:

#!/bin/bash
sudo -u ec2-user -i <<'EOF'
# This will affect only the Jupyter kernel called "conda_python3"
# see <https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-lifecycle-config-install.html>
source activate python3
pip install bamboolib
python -m bamboolib install_nbextensions
source deactivate
EOF

3. Create a Jupyter Notebook Instance

Go to Notebook → Notebook Instances and create a notebook instance. Make sure to add the install-bamboolib lifecycle configuration under Lifecycle configuration

4. Open Notebook and test bamboolib

Click on "Open Jupyter" in order to start a Jupyter Notebook. Please make sure to create a Notebook with the conda_python3 kernel. Then run the following code to test bamboolib:

import bamboolib as bam
df = bam.get_sales_df()
df

Installation for JupyterLab

SageMaker uses JupyterLab version 1.2.18, which is causing some compatibility issues with bamboolib. If you want us to provide compatibility for SageMaker JupyterLab, please send us an email.