How to Use JupyterLab with Python

Kagula

Feb-27-2023

Introduction

        JupyterLab is an extensible environment for interactive and reproducible computing, based on the Jupyter Notebook and Architecture, it's convenient for python engaging with data science and machine learning because it's already brought with Numpy, Pandas, MatPlotLib and Scikit-learn libraries, etc.

Environment

  • Microsoft Windows [Version 10.0.19044.2604]
  • Anaconda-3.2-2022.10
  • python3.9

Content

Installation

       Before installing Anaconda, remove installed Python from the control panel to avoid different Python versions occur conflicts.

        Download the Anaconda3 packet from 'https://www.anaconda.com/' and startup it. choice 'All User' Option to avoid space characters in the install path. The default install path will be 'C:\ProgramData\Anaconda3'. After setup, launch it with Anaconda Navigator and click JupyterLab, after a while, you can see the program is open in Internet Explorer.

The Cell

pic1 Hello world

        The edit region is called 'Cell', we can have many cells. We can run the current cell by pressing 'Ctrl+Enter'. the blue vertical line on the left of the Cell is indicated in command mode.

        If everything is ok, we will see the output below the snippet of python you just have written.

        In the command mode, you can delete the current cell by using the shortcut 'd,d'.

To Access External Files

Step1, create a new snippet for demo:

        Create a new cell and write the snippet like below and save it as 'HelloWorld.ipynb'. 'ipynb' is a file format that is used by Anaconda. 

import pandas as pd
df = pd.read_csv('vgsales.csv') #return a data frame object
df

Step2, download the file which the demo needs:    

    Download vgsales.csv from www.kaggle.com/gregorut/videogamesales, and put it in the directory where 'HelloWorld.ipynb' stays.

Last Step, Run it:

        Press the shortcut 'Ctrl+Enter' to run the snippet of python. if everything is ok you will see the table below the cell.

pic2. the table gets from a CSV file.

Complement

         If the left vertical line of the cell is green, it indicated the cell is in edit mode, you can use the Esc key to switch to command mode.

        Below are some commonly used shortcuts.

  • key 'a' inserts the cell above the current cell.
  • key 'b' inserts the cell below the current cell.
  • key 'Tab' lists the methods of the object.
  • 'Shift+Tab' lists the parameters of the function where your cursor is.
  • 'Ctrl+/'  switches on/off comment before the current line.
  • 'Shift+enter' run the current cell and forward.

Reference

  • www.anaconda.com
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kagula086

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值