Data Science and Machine Learning Flashcards vol.1
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
p4ds
.DS_Store
.gitignore
Data_Wolf_P4DS.ipynb
README.md
_datawolf_nametag.png
ava-icon.png
card0.txt
card1.txt
card10.txt
card11.txt
card12.txt
card13.txt
card14.txt
card15.txt
card16.txt
card17.txt
card18.txt
card19.txt
card2.txt
card20.txt
card21.txt
card22.txt
card23.txt
card24.txt
card25.txt
card26.txt
card27.txt
card28.txt
card29.txt
card3.txt
card30.txt
card31.txt
card32.txt
card33.txt
card34.txt
card35.txt
card36.txt
card37.txt
card38.txt
card39.txt
card4.txt
card40.txt
card41.txt
card42.txt
card43.txt
card44.txt
card45.txt
card46.txt
card47.txt
card5.jpg
card5.txt
card6.txt
card7.txt
card8.txt
card9.txt
favicon.ico
index.md
output_50_0.png
output_52_0.png
output_54_0.png

README.md

Open Source Love License: MIT

Data Wolf: Open Source Data Science

Data Science Flashcards! | BETA

by @pybarrios | January 19th, 2018

POCKET FRIENDLY: View on Instagram!

_datawolf



Table of contents

  1. Flashcard 1 | Math in Python is fun!
  2. Flashcard 2 | Variables
  3. Flashcard 3 | Python lists
  4. Flashcard 4 | For the love of cinema
  5. Flashcard 5 | Slicing lists
  6. Flashcard 6 | Subsetting lists
  7. Flashcard 7 | A list of lists
  8. Flashcard 8 | Replace list items
  9. Flashcard 9 | Built-in functions
  10. Flashcard 10 | Baked-in help
  11. Flashcard 11 | Sorting it all out
  12. Flashcard 12 | String methods
  13. Flashcard 13 | List methods
  14. Flashcard 14 | Importing packages
  15. Flashcard 15 | If this then that
  16. Flashcard 16 | Or else
  17. Flashcard 17 | Just call me elif
  18. Flashcard 18 | Numpy arrays(1)
  19. Flashcard 19 | Numpy arrays(2)
  20. Flashcard 20 | Numpy array indexing
  21. Flashcard 21 | Numpy 2D arrays
  22. Flashcard 22 | The shapes of lists
  23. Flashcard 23 | Lists, mean & median
  24. Flashcard 24 | Lists, mean & median
  25. Flashcard 25 | Matplot scatterplot
  26. Flashcard 26 | Matplot histograms
  27. Flashcard 27 | Python dictionary
  28. Flashcard 28 | Dictionary Earth
  29. Flashcard 29 | Earth keys
  30. Flashcard 30 | Manipulating Earth
  31. Flashcard 31 | Pandas dataframes
  32. Flashcard 32 | Import to CSV
  33. Flashcard 33 | Return of the CSV
  34. Flashcard 34 | Pandas Brackets
  35. Flashcard 35 | loc and iloc
  36. Flashcard 36 | Equality
  37. Flashcard 37 | Compare arrays(1)
  38. Flashcard 38 | Compare arrays(2)
  39. Flashcard 39 | Import CSV to series
  40. Flashcard 40 | Compare Pandas series
  41. Flashcard 41 | While loops
  42. Flashcard 42 | While if loops
  43. Flashcard 43 | For loops
  44. Flashcard 44 | Loops from scratch
  45. Flashcard 45 | Loops of dictionary
  46. Flashcard 46 | Looping over Numpy
  47. Flashcard 47 | Loop over dataframe

Description:

Data Wolf presents: Data Science Flashcards! I made the paper flashcards using MOO busniess cards but you can have them for free on Data Wolf's Instagram.

Getting Started:

Getting Answers:

You have a few options when it comes to gettings answers.

Option 1

You can use Python by writing the function below also known and flashcard(0). You can use the command line:

  • Write this Python 3 function:
def flashcard(my_num):
        import requests
        link = 'http://datawolf.us/p4ds/card'+ str(my_num) +'.txt'
        f = requests.get(link)
        print(f.text)
  • Call this function by typing flashcard(1) in the shell as shown below. For single digit cards do not use 0, just 1-9.
flashcard(1)
>>> 35+16
51
>>> 25-16
9
>>> 3*5
15
>>> 10/2
5.0
>>> 2**7
128
>>> 18%7
4
flashcard(2)
>>> movie = 10
>>> popcorn = 25
>>> movie + popcorn
35
flashcard(3)
>>> a="This list"
>>> b=" demonstrates concatenation."
>>> my_list=a+b
>>> print(my_list)
This list demonstrates concatenation.

Option 2

Alternatively, you can use the QR code on the card.

IMG



Option 3

Jupyter notebooks are often used by Data Scientists. Take a look a Jupyter notebook excerpt below:

Flashcard 0 | This is a function (flashcard)

def flashcard(my_num):
    """This function returns flashcard
    answers by requesting a .txt file 
    from the DataWolf.us website. Just
    type flashcard(1) from command line. """ 
    import requests
    link = 'http://datawolf.us/p4ds/card'+ str(my_num) +'.txt'
    f = requests.get(link)
    print(f.text)

Flashcard 1 | Math in Python is fun!

print(35+16) # <-- Or just type 35+16 (NOTE: if you press enter, it will run.)
print(25-16)
print(3*5)
print(10/2)
print(2**7)
print(18%7)
51
9
15
5.0
128
4

Flashcard 2 | Variables

movie = 10
popcorn = 25

(movie + popcorn) * 2
70

Flashcard 3 | Python lists

a="This list"
b=" demonstrates concatenation."

my_list=a+b

print(my_list)
This list demonstrates concatenation.

Flashcard 4 | For the love of cinema

movie = 10
popcorn = 75

print("Movie costs " + str(movie) +" and popcorn costs " + str(popcorn))
Movie costs 10 and popcorn costs 75

Flashcard 5 | Slicing lists

colors = ["blue", "red", "green"]

print(colors[1])
print(colors[-1])
print(colors[1:])
red
green
['red', 'green']

Flashcard 6 | Subsetting lists

colors = ["blue", "red", "green"]
old_colors = colors[0:2]
new_colors = colors[1:]
print(old_colors)
print(new_colors)
['blue', 'red']
['red', 'green']

Flashcard 7 | A lists of lists

flashcard(7)
>>> list_of_lists = [["a", "b"],["c"],["d","e"]]
>>> list_of_lists[2][1]
'e'

Flashcard 8 | Replace list items

x = ["a", "b", "c", "d"]
x[1] = "r"
x[2:] = "h","j"
print(x)
['a', 'r', 'h', 'j']

Flashcard 9 | Built-in functions

var1 = [1, 2, 3, 4]
var2 = True
var3 = int(var2)

print(len(var1))
print(var3)
4
1

Flashcard 10 | Baked-in help

#help(max) <-- uncomment to get help
#help(iter) <-- uncomment to get help
#help(type) <-- uncomment to get help
help(len) 
Help on built-in function len in module builtins:

len(obj, /)
    Return the number of items in a container.

Flashcard 11 | Sorting it all out

first=[1.0,3.0,5.0]
second=[2.0,4.0]

full = first + second
full_sorted = sorted(full, reverse=True)

print(full_sorted)
[5.0, 4.0, 3.0, 2.0, 1.0]

Flashcard 12 | String methods

doom = "videogame"
doom_up = doom.upper()

print(doom.count('o'))
1

Flashcard 13 | List methods

coins = [.01, .05, .10, .25, 1.00]

print(coins.index(.10))
print(coins.count(.01))
2
1

Flashcard 14 | Importing packages

from math import pi

print(pi)
3.141592653589793

Flashcard 15 | If this then that

doom = "game"
area = 100.0

if doom == "game":
    print("Doom!")
Doom!

Flashcard 16 | Or else

doom = "videogame"
area = 14.0

if doom == "fruit":
    print("an apple!")
else:
    print("not sure")
not sure

Flashcard 17 | Just call me elif

doom = "videogame"
area = 14.0

if doom == "fruit":
    print("an apple!")
elif doom == "videogame":
    print("Game on!")
else:
    print("not sure")
Game on!

Flashcard 18 | Numpy array(1)

import numpy as np

bills = [1, 5, 10, 20, 50, 100, 500]

np_bills = np.array(bills)
print(type(np_bills))
<class 'numpy.ndarray'>

Flashcard 19 | Numpy array(2)

import numpy as np

bills = [1, 5, 10, 20, 50, 100, 500]

np_bills = np.array(bills)
new_currency = np_bills * 26
print(new_currency)
[   26   130   260   520  1300  2600 13000]

Flashcard 20 | Numpy array indexing

import numpy as np

print(bills[1])
print(np_bills[0:4])
5
[ 1  5 10 20]

Flashcard 21 | Numpy 2D arrays

bills = [[1, 5],[10, 20],[50, 100]]

np_bills = np.array(bills)

print(type(np_bills))
<class 'numpy.ndarray'>

Flashcard 22 | The shapes of lists

bills = [[1, 5],[10, 20],[50, 100]]
np_bills = np.array(bills)
print(np_bills.shape)
(3, 2)

Flashcard 23 | Lists, mean & median

bills = [1, 5, 10, 20, 50, 100]

import numpy as np

print(np.mean(np_bills))

print(np.median(np_bills))
31.0
15.0

Flashcard 24 | Lists, mean & median

x = [1,9,5,17]
y = [20,2,24,1]

import matplotlib.pyplot as plt

plt.plot(x,y)
plt.show()

png

Flashcard 25 | Matplot scatterplot

x = [1,9,5,17]
y = [20,2,24,1]

import matplotlib.pyplot as plt

plt.plot(x,y)
plt.show()

png

Flashcard 26 | Matplot histograms

x = [1,9,5,17,20,2,24,1]

import matplotlib.pyplot as plt

plt.hist(x)
plt.show()

png

Flashcard 27 | Python dictionary

countries = ['usa', 'russia', 'china']
capitals = ['washington', 'moscow', 'beijing']

ind_chi = countries.index('china')

print(capitals[ind_chi])
beijing

Flashcard 28 | Dictionary Earth

earth = {'usa:washington','russia:moscow','china:beijing'}

print(earth)
{'usa:washington', 'russia:moscow', 'china:beijing'}

Flashcard 29 | Earth keys

earth = {'usa:washington','russia:moscow','china:beijing'}
print(earth)
{'usa:washington', 'russia:moscow', 'china:beijing'}

Flashcard 30 | Manipulating Earth

earth = {'usa':'washingtown','russia':'moscow','china':'beijing'}
earth['usa'] = 'washington'

earth.pop('russia')

print(earth)
{'usa': 'washington', 'china': 'beijing'}

Flashcard 31 | Pandas dataframe

import pandas as pd

names = ["us","japan","peru","chile"]
eng =  [True, False, False, False] 
ppl = [809,988,101,77]

my_dict = {'country':names,'english':eng,'population':ppl}

lang = pd.DataFrame(my_dict)

print(lang)
  country  english  population
0      us     True         809
1   japan    False         988
2    peru    False         101
3   chile    False          77

Flashcard 32 | Import to CSV

import pandas as pd
import csv
d = pd.read_csv('lang.csv')
print(d)

#Download dataset here: https://datawolf.us/datasets/lang.csv
#Once downloaded, navigate to that folder so python can read it.
  country english  population
0      us    True         323
1   japan   False         127
2    peru   Fasle         131
3   chile   False          17

Flashcard 33 | Return of the CSV

import pandas as pd
import csv
d = pd.read_csv('lang.csv', index_col=0)
print(d)

#Download dataset here: https://datawolf.us/datasets/lang.csv
#Once downloaded, navigate to that folder so python can read it.
        english  population
country                    
us         True         323
japan     False         127
peru      Fasle         131
chile     False          17

Flashcard 34 | Pandas Brackets

import pandas as pd
#lang = pd.read_csv('lang.csv')
print(lang['country'])
#Download dataset here: https://datawolf.us/datasets/lang.csv
#Once downloaded, navigate to that folder so python can read it.
0       us
1    japan
2     peru
3    chile
Name: country, dtype: object

Flashcard 35 | loc and iloc

import pandas as pd

row_labels = ['US', 'JAP', 'PE', 'CH']

lang = pd.read_csv('lang.csv')
lang.index = [row_labels]

print(lang.loc['JAP'])

#Download dataset here: https://datawolf.us/datasets/lang.csv
#Once downloaded, navigate to that folder so python can read it.
country       japan
english       False
population      127
Name: JAP, dtype: object

Flashcard 36 | Equality

True == False,2 == 5,'no' == 'no',False == 1
(False, False, True, False)

Flashcard 37 Import arrays(1)

import numpy as np

my_house = np.array([18.0, 20.0, 10.75, 9.50])
your_house = np.array([14.0, 24.0, 14.25, 9.0])

my_house >= 18
my_house < your_house
array([False,  True,  True, False], dtype=bool)

Flashcard 38 | Import arrays(2)

my_kitchen = 18.0
your_kitchen = 14.0

print(my_kitchen > 10 and my_kitchen < 18)
print(my_kitchen < 14 or my_kitchen > 17)
print(my_kitchen * 2 < your_kitchen * 3)
False
True
True

Flashcard 39 | Import CSV to series

import pandas as pd

row_labels = ['US', 'JAP', 'PE', 'CH']
lang = pd.read_csv('lang.csv', index_col = 0)
lang.index = [row_labels]
ppl = lang['population']

print(ppl)
US     323
JAP    127
PE     131
CH      17
Name: population, dtype: int64

Flashcard 40 | Compare Pandas series

import pandas as pd

lang = pd.read_csv('lang.csv')

row_labels = ['US', 'JAP', 'PE', 'CH']
lang.index = [row_labels]

ppl = lang['population']
big_ppl = ppl > 100
huge_ppl = lang[big_ppl]

print(huge_ppl)
    country english  population
US       us    True         323
JAP   japan   False         127
PE     peru   Fasle         131

Flashcard 41 | While if loops

music = 10
while music > 1:
     print('jamming')
     music = music -1
jamming
jamming
jamming
jamming
jamming
jamming
jamming
jamming
jamming

Flashcard 42 | While if loops

music = 10
while music != 0:
     print('jamming')
     if music > 0:
             music = music -1
else:
     if music < 1:
             music = music +1
jamming
jamming
jamming
jamming
jamming
jamming
jamming
jamming
jamming
jamming

Flashcard 43 | For loops

some_numbers = [1.0,2.3,3.44,1.20,6.50]
for i in some_numbers:
     print(i)
1.0
2.3
3.44
1.2
6.5

Flashcard 44 | Loops from scratch

flashcard(44)
>>> house = [["pool", 191.25], 
...          ["game room", 18.0], 
...          ["music room", 20.0],  
...          ["lounge", 19.50]]
>>> for i in house:
...     print("The " + str(i[0]) + " is " + str(i[1]))
... 
The pool is 191.25
The game room is 18.0
The music room is 20.0
The lounge is 19.5

Flashcard 45 | Loop over dictionary

world = {'spain':'madrid', 'france':'paris', 
 'germany':'bonn', 'norway':'oslo', 
 'italy':'rome', 'poland':'warsaw', 
 'australia':'vienna' }
for key, value in world.items():
     print("the capital of " + str(key) + " is " + str(value))
 
the capital of spain is madrid
the capital of france is paris
the capital of germany is bonn
the capital of norway is oslo
the capital of italy is rome
the capital of poland is warsaw
the capital of australia is vienna

Flashcard 46 | Looping over Numpy

np_bills = np.array([20, 50, 10, 5])
np_coins = np.array([[ 25, 10],[ 1, 5]])
for i in np_bills:
     print(i)
 
20
50
10
5

Flashcard 47 | Loop over dataframe

import pandas as pd

lang = pd.read_csv('lang.csv', index_col = 0)

for lab, row in lang.iterrows() :
    print(lab)
    print(row)
us
english       True
population     323
Name: us, dtype: object
japan
english       False
population      127
Name: japan, dtype: object
peru
english       Fasle
population      131
Name: peru, dtype: object
chile
english       False
population       17
Name: chile, dtype: object