Wk01 - Python /Anaconda Install

Wk01 - Python /Anaconda Instal

1/11/23, 2:38 PM

Wk01 - Python /Anaconda Install

Continue setup - Anaconda/PyCharm Code in python {& pandas} - using Spyder and PyCharm. Read a CSV file, select data from the CSV file. Yahoo Finance and its terminology.

5+1 Steps: . Install Anaconda (python & libraries) . Install scripting/python environment (py3XF). . Test it with Spyder a simple IDE . Test it with PyCharm a more complex IDE. . Write a few python programs (ok... so perhaps more than 3 steps) . Add Packages in PyCharm - see it in Anaconda Navigator (go to 5).

Objectives (more details from the main theme) ? Setup pyCharm ? connect Anaconda Packaging with pyCharm ? create a simple program,

? testing python library installation ? view, read, and process a ,csv file with rows & columns

? read & write ? select rows & columns & subsets ? get data from yahoo finance via python

Incentive: ? create web scraper for a static wikipedia page

? one simple, one more complex ? HINTS: on creating a scraper for dynamic web pages.

Step 1: Get Anaconda: { 10-15 minutes }

Anaconda will make python and its dependencies and libraries

Page 1 of 11

l 6 5 4 3 2 1

Wk01 - Python /Anaconda Instal

1/11/23, 2:38 PM

work seamlessly (almost seamlessly).

Resources: Anaconda: Python versions: 3.10 or later {64 bit OK} Getting Started: getting-started Navigator:

. Download Anaconda for your system (Windows, Mac, Linux)

. Run install file .exe. or pkg. - agree to license. - do recommended defaults

. Next. (think)

. Install additional packages in a Conda Environment:

There are different ways of doing this (packages are listed further below)

We will Use the "Anaconda Navigator" for our demo here.

go to "Environments" in the navigator.

at the bottom click on "Create" to create a new environment

Page 2 of 11

l

Wk01 - Python /Anaconda Instal

1/11/23, 2:38 PM

Step 2: Create a Scripting Environment.

Select Python 3.10.4 when dialog pops up. Name your environment:

py3XD

Note: You could name it whatever you want, but for this class please follow the class naming scheme.

py - is for python 3 is for python branch - there are 2 right now - brand 2, and 3. X is for for version 10 of python, and D is for `Data Science' since the general application of our environment will be finance (and investment as a sub-branch).

Page 3 of 11

l

Wk01 - Python /Anaconda Instal

1/11/23, 2:38 PM

4. To this environment (py3XD) - add the following packages/ libraries [ version is --> at least. ]

(select, then apply in Anaconda navigator). Pandas (1.4.3) NumPy (automatically included with Pandas) 1.23.1 SciPY 1.7.3 (later use) matplotlib 3.5.1 - creating charts, scatter, bar graphs beautifulsoup 4 (4.11.1) - web scraping request (2.28.1) - web scraping selenium (3.141.0) - web scraping (maybe)

We will add more libraries later, as we go

. Write a simple script/program - using the Anaconda Framework

To do this,

We need an editor, OR some sort of Intergraded Development Environment (IDE) that includes and editor BUT also tools to automate running the code, and debugging it.

For now - as quick start - we will use Spyder, we will not use this much later ! (sorry) but it provides a quick start!

In the Anaconda Navigator - menu on left. Hit - Home button.

Step 3: Install Spyder - a simple IDE. . Select our environment py3XD to list Channels for our environment. install - Spyder (5.2.2). 2-3 minutes on a standard wiFI network. Click "Launch"

Page 4 of 11

l

Wk01 - Python /Anaconda Instal

1/11/23, 2:38 PM

. Warmup - Do the embedded tutorial - Spyder. just click on `tutorial' link.



Outline - using spyder (A) & python interpreter (B) A. Run something: add to spyder temp.py the following code:

# Hans Fangohr, University of Southampton, UK def hello():

"""Print "Hello World" and return None.""" print("Hello World")

# Main program starts here hello()

Page 5 of 11

l

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download