Skip to content
Open

Hi #1

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b784a46
Create README.md
ravescovi Jan 7, 2020
bf5b521
Update README.md
ravescovi Jan 7, 2020
cba34bf
Update README.md
ravescovi Jan 7, 2020
91c4ebc
Assigment1
ravescovi Jan 10, 2020
9ffdcd9
updates
ravescovi Feb 3, 2020
4a5da62
updates
ravescovi Feb 3, 2020
f52fe34
updates
ravescovi Feb 3, 2020
de76581
setup
ravescovi Feb 3, 2020
495a85a
Updates
ravescovi Feb 4, 2020
bcf90f9
Merge branch 'master' of https://github.com/ravescovi/python_for_anal…
ravescovi Feb 4, 2020
f6927d2
updates
ravescovi Feb 4, 2020
8d821b7
update
ravescovi Feb 4, 2020
0ab5d46
Updates
ravescovi Feb 5, 2020
4189e4c
correct packaging
ravescovi Feb 5, 2020
5b5ab38
correct packaging
ravescovi Feb 5, 2020
f807b8a
new things
ravescovi Feb 5, 2020
32cf961
new things
ravescovi Feb 5, 2020
8bb25b8
new things
ravescovi Feb 5, 2020
a00ecd2
new things
ravescovi Feb 5, 2020
a9c620d
new things
ravescovi Feb 5, 2020
fb2a5f0
fix
ravescovi Feb 5, 2020
a6f3978
fix
ravescovi Feb 5, 2020
451b17b
fix
ravescovi Feb 5, 2020
4ecb313
new commit
ravescovi Feb 12, 2020
90affd4
Merge branch 'master' of https://github.com/ravescovi/python_for_anal…
ravescovi Feb 12, 2020
3d66f0d
Added function
Feb 12, 2020
8b90deb
Merge branch 'master' into Lucia's-addition
ravescovi Feb 12, 2020
8eb911b
Merge pull request #1 from LUCIA-RONCHI/Lucia's-addition
ravescovi Feb 12, 2020
9df3423
nn
adajing0101 Feb 12, 2020
da69ba2
Merge pull request #2 from adajing0101/master
ravescovi Feb 17, 2020
7fc4a33
new things
ravescovi Feb 18, 2020
e3a24bb
raf
ravescovi Feb 19, 2020
6fd6f5d
rebase
ravescovi Mar 2, 2020
eb99d7d
rebase
ravescovi Mar 2, 2020
b0fe6a8
rebase
ravescovi Mar 3, 2020
169adcd
assign3
ravescovi Mar 10, 2020
9405614
New quarter
ravescovi Apr 9, 2020
a520125
422
ravescovi Apr 23, 2020
fc420e2
422
ravescovi Apr 23, 2020
cda0735
Update
ravescovi May 4, 2020
38371c9
Class 6
ravescovi May 13, 2020
d10f870
Ch4
ravescovi Jun 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

*checkpoint.ipynb
*.pkl
*.pyc
/dist/
/*.egg-info
__pycache__
/build*/*
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Welcome to University Of Chicago's Python For Analytics
This course introduces the python language of programming to students who are preparing to study analytics and data science

Please follow the instructions below to get your computer ready for this class.

_Note Mac users: Once software is downloaded, if you double click to launch it, you may get permission errors. Try to right click on the downloaded software, pick "open" and continue. (Apple is trying to protect you from accidentally starting malware/virus)_

## Install Python (anaconda distribution)
Please install Python 3.x from this website: https://www.anaconda.com/distribution/
(do not install 2.7, it will be discontinued soon.)

Mac users:
Accept all default prompts

Windows users:
Accept all default prompts, **except** "Add Anaconda to my PATH envrionment variable." Make sure this is checked.

Anaconda's distribution of Python is widely used in the industry, particularly among data scientists. This distribution makes it easy to use many libraries and packages for data analysis, building models, visualization, etc.

#### Aditional steps:
Execute these statements at the terminal (Windows users should use Anaconda Prompt)
- `jupyter contrib nbextension install --user`
- `jupyter nbextensions_configurator enable --user`

Once installed, please start jupyter notebook and execute code provided below
1. Start `Anaconda Navigator` and click `Launch` on the panel labeled `Jupyter Notebook`
2. Create new notebook from the web interface
3. Execute this code:
```
%%timeit
sum(range(1_000_000))
```
4. Execute this code:
```
from psutil import virtual_memory, disk_usage, cpu_count, os

bytes_in_gb = 1024**3

print("Memory:\t",round(virtual_memory().total/bytes_in_gb,4), "Gigabytes")
print("Disk:\t",round(disk_usage(os.path.abspath(os.sep)).total/bytes_in_gb,4), "Gigabytes")
print("CPUs:\t", cpu_count())
```

## Install Git
Please intall Git, a version control sotware, from this website: https://git-scm.com/downloads (you are ok to use default settings)

Note that this is a command-line tool. Once installed, you may not see a new icon to click. We will install a Desktop client to remedy this.

Although we don't make heavy use of version control, you will be introduced to the concept. Installing Git also installs "Git Bash," and comand line environment which simulates Unix/Linux. We will do several exercises which will require this environment.

## Clone this repository [Optional on day 1]
1. Visit this web page: https://github.com/ravescovi/python_for_analytics
2. Click "Clone or download" and pick the "Download ZIP" option (unless you already have a GitHub account)

196 changes: 196 additions & 0 deletions assigments/NAME_SURNAME_ASSIGN_1_1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Assignment 1 - 1\n",
"* Topics: containers, udfs, comprehensions, error handling"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Question 1\n",
"* Create a function that takes 2 lists as params, of equal length and does the following:\n",
" * returns a dictionary where the keys are the first list and the values are the second list\n",
" * make use of zip and comprehension to make the dictionary\n",
" * if the lists are not of equal length, use error handling to indicate the mismatch"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# a = [5,7]\n",
"# b = [\"x\", \"z\"]\n",
"# return {5:\"x\", 7:\"z\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = [1,2,3,4,5,6,7,8]\n",
"b = [\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Question 2\n",
"* Create a UDF that takes a list and returns the permutations and combinations (length 2) as nested lists, along with the number of permutations and combinations. \n",
"* The function should return 4 things"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"a = [1,2,3,4,5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Question 3\n",
"* Map a function to the below list that\n",
" * returns the remainder of each number divided by 3 (52/3 = 17 with a remainder of 1, we want the 1 to be returned)\n",
" * use lambdas for the mapping\n",
" * hint, look at modulus (%) in python"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"lst = list(range(100))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Question 4\n",
"* Using comprehension, replace the keys in the list with their value in the dictionary\n",
"* example below"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# lst = [1,2]\n",
"# dict = {1:\"a\", 2:\"b\"}\n",
"# new_lst = [\"a\",\"b\"]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"a = list(range(5))\n",
"dct = {\n",
" 0:\"a\",\n",
" 1:\"b\",\n",
" 2:\"c\",\n",
" 3:\"d\",\n",
" 4:\"e\"\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Question 5\n",
"* Make a UDF that takes a variable amount of numbers and returns a list with the numbers having been squared\n",
"* use comprehension to perform the squaring of each item\n",
"* hint, this should be doable in one line using args"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"def my_func(*x):\n",
" return [x[i]*x[i] for i in range(len(x))]"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"b = my_func(1,2,3,4,5,6,7)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 2, 3, 4, 5, 6, 7]\n",
"[1, 4, 9, 16, 25, 36, 49]\n",
"<class 'list'>\n"
]
}
],
"source": [
"print(a)\n",
"print(b)\n",
"print(type(b))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading