![]() ![]() The application code goes in the blake/ directory. Here’s how these commands will look in the notebook: Accessing application code in notebook import pandas as pdĭata =, , ]ĭf = pd.DataFrame(data, columns = ) Then run this series of commands in the subsequent cells to create a Pandas DataFrame. Run 2 + 2 in the first cell to make sure the notebook can run a basic Python command. Create notebookĬlick Untitled at the top of the page that opens and rename the notebook to be some_pandas_fun: Rename notebook Go to the notebooks folder and click New => Notebook: Python 3 to create a notebook. Run jupyter notebook to open the project with Jupyter in your browser.Ĭlick New => Folder to create a folder called notebooks/. This is the key step that lets you run a Jupyter notebook with all the right project dependencies. Run poetry shell in your Terminal to create a subshell within the virtual environment. If you cloned the blake repo, you could simply run poetry install to setup the virtual environment. This is referred to as the “virtual environment” of your project. This command downloads a bunch of Python code in the ~/Library/Caches/pypoetry/virtualenvs/blake-Y_2IcspR-p圓.7/ directory. Run poetry add pandas jupyter ipykernel to install the dependencies that are required for running notebooks on your local machine. We’ll investigate the contents of these files later in this post. ![]() ![]() All the code covered in this post is in a GitHub repo, but it’s best to run all the commands on your local machine, so you learn more.Ĭhange into the blake directory with cd blake and examine the file structure: blake/ Install Poetry and run the poetry new blake command to create a project called blake. This post shows how to manage environments with Poetry, but you can also use conda of course. This workflow saves you from dependency hell. You’ll often find yourself in dependency hell when trying to setup someone else’s repo with Jupyter notebooks. Python dependency management is hard, especially for projects with notebooks. Your teammates can easily run poetry install to setup an identical Jupyter development environment on their computers. The workflow outlined in this post makes projects that can easily be run on other machines. Poetry is a robust dependency management system and makes it easy to make Python libraries accessible in Jupyter notebooks. Poetry makes it easy to install Pandas and Jupyter to perform data analyses. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |