!conda config --add channels conda-forge
!conda install -c conda-forge -y git
!conda install -c conda-forge -y jupyterlab-git
!conda update -y pexpect
Introduction to Data Science
What is Data Science?
Important Information
Email: joanna_bieri@redlands.edu
Office Hours take place in Duke 209 – Office Hours Schedule
Class Website:
Announcements
Today your goal is to get your computer set up!
Please come to lab
Setting up your computer.
The first thing you need to do to be successful in this class is get your computer set up so you can use all the data science tools. You should be able to just follow the steps in this notebook, but please come get help if you need it.
2. Install/Open JupyterLab:
Once Anaconda is installed open up the navigator. You don’t need to sign up for an account! It should look something like this.
- Look for JupyterLab and click Install or Launch depending on what you see. This is what the install button looks like:
Once it is installed click Launch. This will open JupyterLab in a browser window. You will see a list of files on the left side of the page and the Launcher on the right side of the page.
Make a note of where your files are being saved! Sometimes you will need to access them using Finder or Windows Explorer.
Now make yourself a new folder just for our class by clicking on the icon in the top left corner:
Name the folder anything you want - Data101 is a good name - and then double click on it to enter the folder.
Now we are ready to make a new file. In the launcher window, Click on the Python 3 notebook.
This will open up your first notebook named Untitled.ipynb
Once the notebook is open we are ready to start installing packages you will need.
- Jupyter notebooks are organized in cells (gray space). This is where you can type in your code. To run the cell either push the run button at the top of the notebook, or press SHIFT-ENTER.
3. Install GIT packages for JupyterLab:
In the JupyterLab Notebook that you just opened:
- Install GIT and the JupyterLab git extension, copy and paste the commands below:
- Hover with your mouse and click the clipboard to copy
- Click on a cell in your JupyterLab notebook
- Use CTRL-v or COMMAND-v to paste
- Run the cell
A bunch of things will be installed from Anaconda (a trusted source). Let all of the commands finish running. This might take a while
- Restart JupyterLab by closing the tab in your browser and then clicking Launch again in Anaconda Navigator. Now you should see a tab on the left hand side for Git. This is the icon:
- Click on this tab to see the options
4. Sign up for a GitHub account:
Click the link below to open GitHub in a new browser window.
- Enter your University of Redlands email address and click continue
- Create a password
- Create a user name - be professional here since GitHub is a great place to show future employers projects that you have worked on.
- Solve the weird puzzle to prove you are a human.
- Check your university of Redlands email to verify your account.
- Sign in to GitHub
- Now it will ask you some questions: You are a student and using this just for yourself. You can ignore all the extra packages it suggests and just hit continue.
- When asked about what kind of subscription you want, you can Continue for Free unless you want to explore some more advanced features that we won’t use in this class
5. Clone the files for Redlands-Data101, Create your own Repo, and set up Personal Access Tokens
- Here is link to our class GitHub organization.
clicking on it you should see something like:
Now our goal is for you to get your own copy of these files both on your GitHub account and on your computer. To do this we need to Clone the REPO. Below are step by step instructions for doing this, but it is a little complicated so I also created a video.
Video Instructions:
- Here is a video walking you through the process described below How to use GitHub video
Step By Step Instructions:
Clone
- First you want to pull the class files from the cloud down to your computer, aka Clone. We first get a link from GitHub then switch to JupterLab to enter the link.
Click on the <> Code button
GitHub Clone Link to get the drop down menu
GitHub Clone Link Copy the HTTPS link
Switch over to JupyterLab and select the GitHub tab
from the icons on the left.
Git Clone Click on the Clone a Repository button and paste in the HTTPS link and click clone
Now you should see the folder FALL25 in your JupyterLab files - click into that folder and open some of the files.
- This will create a copy of the class files on your computer. During the semester you will Pull the files down to your computer as I add new material.
Now make yourself a working folder
- You will want a Git repo just for your work. This is where you will store a backup of all the code you write in class. Later in the class we will learn how to collaborate using Git.
Make sure you are at your GitHub home screen by clicking on the cat in the upper left corner.
Now create your own repo by clicking on the “New” button on the top left side of the screen
GitHub Home Repo This will send you to a page that you can fill out to create your repo. You should enter a file name that is easy to search for and different from FALL25. You can choose to make your repo public or private. I usually add a README file and choose a Python .gitignore.
GitHub Create Repo Now you have your own repo that you can clone into JupyterLab.
GitHub New Repo Next you can Clone this repo to your JupyterLab - just like we did above with the class Repo.
Try making and committing changes
GitHub is really great because it can save all of your code changes over time. This means if your computer breaks down you still have all the files you sent back up the GitHub. TO accomplish this we need to make changes Stage the changes, Commit the changes, and then Push them back up to GitHub.
Try opening the README.md file in your personal code folder and make a change. Save your change (CONTROL+S or COMMAND+S or push the save button
).
Now that you have saved your changes to the files you are ready to Stage your changes.
You should see a changed file in the Git tab
. If you scroll over the file you will see a + button. Push the + button to Stage the change.
Changed File Staged File You are now ready to Commit
Type in a Summary (required) and a Description (optional) and hit the COMMIT button
Commit Changes - It might ask for a name and email address - enter your name and Redlands email
Push your changes up to GitHub
Now you are ready to send your changes to GitHub, aka Push. To do this we will need to generate a personal access token. A PERSONAL ACCESS TOKEN IS NOT YOUR PASSWORD. Follow the directions carefully:
To push your changes, use the cloud buttons
- Down Arrow = Pull changes down from the cloud
- Up Arrow = Push changes up to the cloud and an orange dot means there are changes to push
Click the button with the orange dot.
At this point it will ask you for your username and personal access token
Enter Credentials - SWITCH TABS to your GitHub account and click on the user icon in the top right corner to get the drop down menu. In the image below my icon looks like an orange jack-o-lantern face, yours will be some abstract design.
Drop Down Menu - Settings Click on settings
In the page that appears, you want to select developer tools from the menu on the left. It will be at the bottom and look like this:
Developer Settings Developer Settings Page Click on the Personal Access Tokens tab and choose Tokens (classic)
Then click on the link on the right named Generate new token and choose Generate new token (classic) from the drop down menu.
Personal Access Token to see the page:
Personal Access Token Make a note about the token, choose an expiration date (I pick something after the end of the semester), and click the button to highlight repo. Ignore the rest.
Scroll to the bottom and click the green generate token button. You should see something like:
Example Token NEVER SHARE YOUR TOKEN!!! It is like sharing your password – don’t do it!
Copy the token (this is the only time you will see it.)
Now enter this information in JupyterLab
Enter Credentials
Your data will be pushed to GitHub
If you get an error you might need to install xcode developer tools. On a mac this generates a pop up that looks like:
Enter Credentials
Save the Token!
- You will want to save this token so you don’t have to memorize it or look it up in a file on your computer
In JupyterLab select the Git menu from the bar at the top
Git Menu And “Open Git Repository in Terminal”
You will see a tab pop up with a bunch of text probably followed by a dollar sign
Git Menu After the dollar sign type in the following (or copy and paste it below) and hit enter
Git Menu
--global credential.helper store git config
- Now your personal access token is saved (WARNING *this is saved as plain text, not secure for a shared computer)
Why are you making me do this Joanna!?!?!?
GitHub is what professionals in industry use. It is good to get some experience early. It also gives you a backup of all your work, just in case your computer crashes or dies completely. It is also GREAT for professional collaborations. Two or more people can push and pull from the same repository! We will learn more about this later in the semester.
- Clone means to get a copy of your code from GitHub onto your computer - do this once
- Stage means you made changes you are ready to commit.
- Commit means make a bookmark of these changes they are good.
- Push means to send your changes from your computer up to GitHub - you can only push to your account or an account where you have the right permissions
- Pull means to refresh your copy of the code getting stuff from GitHub down onto your computer - you can pull from any cloned repo
- Fork means to get a copy of the code from someone else’s GitHub to your GitHub. This is great for colaborating on code and merging changes - more on this later.
graph LR subgraph Cloud A[GitHub: My Repo] -.->B(Clone Once) Z[GitHub: Class Repo] -.->X(Clone Once) end C(( JupyterLab <br/> Make Changes <br/> )) subgraph Local C -.-> D(Stage and <br/> Commit <br/> Changes)-.-> C end C <==> Y[Push/Pull Changes] <==> A Z ==> W[Pull Changes] ==> C X --> C B --> C
You are done!
This is all you need for your basic setup - whats next?
Start playing around with the files that you cloned.
Look up a Python Tutorial (introduction) to get a head start.
Check out the extensions tab
- I like to add a spellchecker, but there are lots of things to explore.
Go to settings and change your Theme
Push all the buttons!