Skip to content

Commit 5058eb4

Browse files
committed
first commit
0 parents  commit 5058eb4

File tree

3 files changed

+307
-0
lines changed

3 files changed

+307
-0
lines changed

.gitignore

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
2+
# Created by https://www.gitignore.io/api/macos,pycharm,jupyternotebook,visualstudiocode
3+
# Edit at https://www.gitignore.io/?templates=macos,pycharm,jupyternotebook,visualstudiocode
4+
5+
### JupyterNotebook ###
6+
.ipynb_checkpoints
7+
*/.ipynb_checkpoints/*
8+
9+
# Remove previous ipynb_checkpoints
10+
# git rm -r .ipynb_checkpoints/
11+
#
12+
13+
### macOS ###
14+
# General
15+
.DS_Store
16+
.AppleDouble
17+
.LSOverride
18+
19+
# Icon must end with two \r
20+
Icon
21+
22+
# Thumbnails
23+
._*
24+
25+
# Files that might appear in the root of a volume
26+
.DocumentRevisions-V100
27+
.fseventsd
28+
.Spotlight-V100
29+
.TemporaryItems
30+
.Trashes
31+
.VolumeIcon.icns
32+
.com.apple.timemachine.donotpresent
33+
34+
# Directories potentially created on remote AFP share
35+
.AppleDB
36+
.AppleDesktop
37+
Network Trash Folder
38+
Temporary Items
39+
.apdisk
40+
41+
### PyCharm ###
42+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
43+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
44+
45+
# User-specific stuff
46+
.idea/**/workspace.xml
47+
.idea/**/tasks.xml
48+
.idea/**/usage.statistics.xml
49+
.idea/**/dictionaries
50+
.idea/**/shelf
51+
52+
# Generated files
53+
.idea/**/contentModel.xml
54+
55+
# Sensitive or high-churn files
56+
.idea/**/dataSources/
57+
.idea/**/dataSources.ids
58+
.idea/**/dataSources.local.xml
59+
.idea/**/sqlDataSources.xml
60+
.idea/**/dynamic.xml
61+
.idea/**/uiDesigner.xml
62+
.idea/**/dbnavigator.xml
63+
64+
# Gradle
65+
.idea/**/gradle.xml
66+
.idea/**/libraries
67+
68+
# Gradle and Maven with auto-import
69+
# When using Gradle or Maven with auto-import, you should exclude module files,
70+
# since they will be recreated, and may cause churn. Uncomment if using
71+
# auto-import.
72+
# .idea/modules.xml
73+
# .idea/*.iml
74+
# .idea/modules
75+
76+
# CMake
77+
cmake-build-*/
78+
79+
# Mongo Explorer plugin
80+
.idea/**/mongoSettings.xml
81+
82+
# File-based project format
83+
*.iws
84+
85+
# IntelliJ
86+
out/
87+
88+
# mpeltonen/sbt-idea plugin
89+
.idea_modules/
90+
91+
# JIRA plugin
92+
atlassian-ide-plugin.xml
93+
94+
# Cursive Clojure plugin
95+
.idea/replstate.xml
96+
97+
# Crashlytics plugin (for Android Studio and IntelliJ)
98+
com_crashlytics_export_strings.xml
99+
crashlytics.properties
100+
crashlytics-build.properties
101+
fabric.properties
102+
103+
# Editor-based Rest Client
104+
.idea/httpRequests
105+
106+
# Android studio 3.1+ serialized cache file
107+
.idea/caches/build_file_checksums.ser
108+
109+
### PyCharm Patch ###
110+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
111+
112+
# *.iml
113+
# modules.xml
114+
# .idea/misc.xml
115+
# *.ipr
116+
117+
# Sonarlint plugin
118+
.idea/sonarlint
119+
120+
### VisualStudioCode ###
121+
.vscode/*
122+
!.vscode/settings.json
123+
!.vscode/tasks.json
124+
!.vscode/launch.json
125+
!.vscode/extensions.json
126+
127+
### VisualStudioCode Patch ###
128+
# Ignore all local history of files
129+
.history
130+
131+
# End of https://www.gitignore.io/api/macos,pycharm,jupyternotebook,visualstudiocode

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<img src="https://bit.ly/2VnXWr2" alt="Ironhack Logo" width="100"/>
2+
3+
# Lab | Numpy Deep Dive
4+
5+
## Introduction
6+
7+
An important ability of a data scientist/data engineer is to know where and how to find information that helps you to accomplish your work. In the exercise, you will both practice the Numpy features we discussed in the lesson and learn new features by looking up documentations and references. You will work on your own but remember the teaching staff is at your service whenever you encounter problems.
8+
9+
## Getting Started
10+
11+
Open the `main.py` file in the `your-code` directory with your favorite text editor. There are a bunch of commentations starting with `#` which instruct what you are supposed to do step by step. Follow the order of the instructions from top to bottom. Read each instruction carefully and provide your answer beneath it. You should also test your answers in Python in the terminal to make sure your responses are correct. If one of your responses is incorrect, you may not be able to proceed because later responses may depend upon previous responses.
12+
13+
For instance, in the first few lines of `main.py`, you see:
14+
15+
```python
16+
#1. Import the NUMPY package under the name np.
17+
18+
#2. Print the NUMPY version and the configuration.
19+
```
20+
21+
You will write the codes as instructed:
22+
23+
```
24+
#1. Import the NUMPY package under the name np.
25+
import numpy as np
26+
27+
#2. Print the NUMPY version and the configuration.
28+
print(np.version.version)
29+
"""
30+
1.15.2
31+
"""
32+
```
33+
34+
:bulb: The `#` sign in Python allows you to make single-line commentation. The `"""` (triple quotes) allows you to make multi-line commentation. Remember you always need a pair of triple quotes and you insert your commentations in between.
35+
36+
Continue answering each question until you reach the end of `main.py`.
37+
38+
## Deliverables
39+
40+
- `main.py` with your responses to each of the instructions.
41+
42+
## Submission
43+
44+
Upon completion, add your version of `main.py` to git. Then commit git and push your branch to the remote.
45+
46+
## Resources
47+
48+
Some of the questions in the assignment are not covered in our lesson. You will learn how to efficiently look up the information on your own. Below are some resources you can find the information you need.
49+
50+
[Numpy User Guide](https://docs.scipy.org/doc/numpy/user/index.html)
51+
52+
[Numpy Reference](https://docs.scipy.org/doc/numpy/reference/)
53+
54+
[Google Search](https://www.google.com/search?q=how+to+use+numpy)
55+
56+
## Additional Challenges for the Nerds
57+
58+
If you are way ahead of your classmates and willing to accept some tough challenges about Numpy, take one or several of the following Codewar *katas*. You need to already possess a good amount of knowledge in Python and statistics because you will need to write Python functions, do loops, write conditionals, and deal with matrices. Add your responses to the katas to `your-code` and submit to the instructor.
59+
60+
* [Weird matrix multiplication](https://www.codewars.com/kata/weird-matrix-multiplication)
61+
* [Insert dashes](https://www.codewars.com/kata/insert-dashes)
62+
* [Thinkful - Logic Drills: Red and bumpy](https://www.codewars.com/kata/thinkful-logic-drills-red-and-bumpy)

your-code/main.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#1. Import the NUMPY package under the name np.
2+
3+
4+
5+
#2. Print the NUMPY version and the configuration.
6+
7+
8+
9+
#3. Generate a 2x3x5 3-dimensional array with random values. Assign the array to variable "a"
10+
# Challenge: there are at least three easy ways that use numpy to generate random arrays. How many ways can you find?
11+
12+
13+
14+
#4. Print a.
15+
16+
17+
18+
#5. Create a 5x2x3 3-dimensional array with all values equaling 1.
19+
#Assign the array to variable "b"
20+
21+
22+
23+
#6. Print b.
24+
25+
26+
27+
#7. Do a and b have the same size? How do you prove that in Python code?
28+
29+
30+
31+
32+
#8. Are you able to add a and b? Why or why not?
33+
34+
35+
36+
#9. Transpose b so that it has the same structure of a (i.e. become a 2x3x5 array). Assign the transposed array to varialbe "c".
37+
38+
39+
40+
#10. Try to add a and c. Now it should work. Assign the sum to varialbe "d". But why does it work now?
41+
42+
43+
44+
#11. Print a and d. Notice the difference and relation of the two array in terms of the values? Explain.
45+
46+
47+
48+
49+
#12. Multiply a and c. Assign the result to e.
50+
51+
52+
53+
#13. Does e equal to a? Why or why not?
54+
55+
56+
57+
58+
#14. Identify the max, min, and mean values in d. Assign those values to variables "d_max", "d_min", and "d_mean"
59+
60+
61+
62+
63+
#15. Now we want to label the values in d. First create an empty array "f" with the same shape (i.e. 2x3x5) as d using `np.empty`.
64+
65+
66+
67+
68+
"""
69+
#16. Populate the values in f. For each value in d, if it's larger than d_min but smaller than d_mean, assign 25 to the corresponding value in f.
70+
If a value in d is larger than d_mean but smaller than d_max, assign 75 to the corresponding value in f.
71+
If a value equals to d_mean, assign 50 to the corresponding value in f.
72+
Assign 0 to the corresponding value(s) in f for d_min in d.
73+
Assign 100 to the corresponding value(s) in f for d_max in d.
74+
In the end, f should have only the following values: 0, 25, 50, 75, and 100.
75+
Note: you don't have to use Numpy in this question.
76+
"""
77+
78+
79+
80+
81+
"""
82+
#17. Print d and f. Do you have your expected f?
83+
For instance, if your d is:
84+
array([[[1.85836099, 1.67064465, 1.62576044, 1.40243961, 1.88454931],
85+
[1.75354326, 1.69403643, 1.36729252, 1.61415071, 1.12104981],
86+
[1.72201435, 1.1862918 , 1.87078449, 1.7726778 , 1.88180042]],
87+
88+
[[1.44747908, 1.31673383, 1.02000951, 1.52218947, 1.97066381],
89+
[1.79129243, 1.74983003, 1.96028037, 1.85166831, 1.65450881],
90+
[1.18068344, 1.9587381 , 1.00656599, 1.93402165, 1.73514584]]])
91+
92+
Your f should be:
93+
array([[[ 75., 75., 75., 25., 75.],
94+
[ 75., 75., 25., 25., 25.],
95+
[ 75., 25., 75., 75., 75.]],
96+
97+
[[ 25., 25., 25., 25., 100.],
98+
[ 75., 75., 75., 75., 75.],
99+
[ 25., 75., 0., 75., 75.]]])
100+
"""
101+
102+
103+
"""
104+
#18. Bonus question: instead of using numbers (i.e. 0, 25, 50, 75, and 100), how to use string values
105+
("A", "B", "C", "D", and "E") to label the array elements? You are expecting the result to be:
106+
array([[[ 'D', 'D', 'D', 'B', 'D'],
107+
[ 'D', 'D', 'B', 'B', 'B'],
108+
[ 'D', 'B', 'D', 'D', 'D']],
109+
110+
[[ 'B', 'B', 'B', 'B', 'E'],
111+
[ 'D', 'D', 'D', 'D', 'D'],
112+
[ 'B', 'D', 'A', 'D', 'D']]])
113+
Again, you don't need Numpy in this question.
114+
"""

0 commit comments

Comments
 (0)