Hi!¶

Today's exercises require you to have¶

1. Installed Anaconda. If you haven't, go to 1.2 in the class textbook (ledatascifi.github.io) and get that installed.¶

2. Finished at least step 3.A of the github exercises.¶

Hello everyone!¶

Our plan for the day:

  1. Any issues with the set up tasks or github exercises?
  2. Big picture
  3. JLab tour
  4. Learning by doing
    1. Opening Jupyter Lab and exploring the interface
    2. Creating our first file and exploring "notebooks"
    3. Practice

Big picture¶

  • python is a programming language
  • .py files are text files that exclusively contain python code.
  • .py files can not show results - you have to output any graphs or tables to new files.

That last feature is a bummer. There must be a better way!

Enter notebook files!

  • .ipynb ("notebook") files mix python code with formatted markdown text and the output from code!
  • For example, the CAPM notebook from last class. Compare it to a basic py file doing the same thing. I know which I prefer!

The result: → better analysis! ("reproducible, reusable, and shareable")

And Jupyter Lab is how we will make our Jupyter notebooks.

Exercises¶

Wait! Don't we have guidance on a few steps we should do as we work?¶

Always use the github workflow!¶

Since we are working, let's put the Github workflow into practice:

  1. Open github desktop
  2. "Fetch" your class notes repo (probably nothing changed, but its a good habit!)
  3. Fetch the class textbook (ledatascifi-2023, which has new handouts and slides)

Now we are ready to work!

Before each class starts, you should have already

  • "fetched" your class notes repo
  • "fetched" the class textbook (ledatascifi-2023), so you can copy exercise files from the textbook to your class notes repo
  • opened JLab

And at the end of each class,

  • save all open code files,
  • commit and push your Class Notes repo
  • close JLab (and the terminal running it)

A quick tour of Jupyter Lab¶

To open Jupyter Lab:

  • Windows: Open Anaconda Prompt and type jupyter lab and hit enter
  • Mac: Open a terminal window and type jupyter lab and hit enter

OK, what are we looking at?

  • This is a browser based editor
  • Notice your prompt/terminal is running in the background
    • HINT : If you need another prompt/terminal to do something else, just open a second one

Now, let me give you a little tour (just watch me!)

I'll cover...

  • The left sidebar
    • The file browser:
      1. Nav to my textbook folder to copy today's exercises
      2. Nav to my Class Notes folder, create a folder called "Exercises"
      3. Go into the Exercises folder you just made and paste the exercises ipynb file there
      4. Open your "Module 1 Notes" file and the exercise file from inside your notes folder
    • Kernels: A list of running code
    • Extensions: VERY useful to make JLab more powerful (see 1.2 and 1.6)
  • The main work area
    • you arrange documents (notebooks, text files, etc.) and other activities (terminals, code consoles, etc.) into panels
    • each panel can have many tabs open

Let's all do those steps above, together¶

After those are done, in the "Module 1 Notes" file from your own class notes folder:

  • go down to the "Jupyterlab Notes" part of the file
  • under it, there is "put your notes here". Replace that with print("Hello world!") (don't forget both quote marks or parentheses)
  • hit the "play" button to run the cell

Three (non-coding) lessons for today¶

  1. Textbook 1.6.2
  2. Textbook 1.7.3
    • I saw this error on 25% (15%) {8%} of assignments 3 (2) {1} years ago... hope for 0% this year!
  3. View discomfort as a postitive signal for your growth here

Time for exercises¶

Start at step 3 of the exercise file

  • If you got behind on the copy/paste steps above, you can open the exercises here: https://github.com/LeDataSciFi/ledatascifi-2023/blob/main/handouts/Jupyterlab%20exercises.ipynb

FIN for the exercises¶

  1. How did we do? (Quick poll)
  2. Obviously, we will learn much more going forward, but you have enough to play around with Jupyter now. I highly recommend
    • reading 1.1-1.8
    • start the assignment
    • tutorials: chapter 1.7 (python) and the syllabus have options

More practice, time permitting:¶

  1. "Issue demo": Have student put issue on their Assignment 1 Repo and tag me. I’ll reply via email.
  2. "Good citizen demo": Have student suggest a typo fix on the website or alter some text

Summary¶

Before each class starts, you should have already

  • "fetched" your class notes repo
  • opened JLab to that folder

And at the end of each class, (do these now!)

  • save all open code files,
  • close JLab (and the terminal running it)
  • commit and push your Class Notes repo
  • open the GitHub.com version of the repo

Code must run from beginning to end and produce the same thing every time

  • Restart the kernal and clear output
  • Run all cells

Before next time¶

Stuck?

  • shift + tab; help(function); find the documentation via google; stack overflow;

Over the weekend:

  • The task page lists reading to cover and coding to try
  • I added a Markdown tutorial to the textbook that people like a lot
  • On Monday, we will be coding together - more updates on that soon