I'm trying to set the working directory for a Google Colab notebook to the location where the notebook resides in Google Drive without manually copying-pasting the folderpath. The motivation is to allow copies of the notebook to function in place and dynamically set the working directory to the location of the notebook without having to manually copy and paste the location to the code.
I have code to mount the notebook to Google Drive and know how to set the working directory but would like to have a section of code that identifies the location of the notebook and stores it as a variable/object.
## Mount notebook to Google Drive
from google.colab import drive
drive.mount("/content/drive", force_remount=True)
## Here is where i'd like to save the folderpath of the notebook
## for example, I would like root_path to ultimately be a folder named "Research" located in a Shared Drive named "Projects"
## root_path should equal '/content/drive/Shared drives/Projects/Research'
## the notebook resides in this "Research" folder
## then change the working directory to root_path
os.chdir(root_path)