Data Science test 2

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

14 Terms

1
New cards

Given the following array X, identify what element is in position 4 

X = np.array([2, 4, 5, 6, 12, 5, 6])

12

2
New cards

What Python call would you make to find the location of 12 in array X? 

np.where(X == 12)

3
New cards
  1. Suppose you had the following paired arrays which correspond to a student’s classes and their grades. Write the Python code that you would use to find the names of classes which the student has below a 70. 

class_names = [“Biology”, “Writing”, “Physics”, “Literature”, “Math”, “History”, “Photography”]

class_scores = [69, 75, 84, 95, 91, 58, 82]

idx = np.where(class_scores < 70)

class_names[idx]

# or

id_c = class_scores < 7

class_names[id_c]

4
New cards

Use the Pokemon Dataset as a reference to answer the following questions. How would you create a new dataframe which only includes Pokemon who have a Type 1 listed as Grass

Grass_cond = df_pokemon[“Type1”] == “Grass”

Df_grass = df_pokemon[Grass_cond]

5
New cards

What if you want a new dataframe of only Pokemon who are Type 1 or Type 2 Poison ? How would you find out how many Pokemon meet this criteria? 

poison_T1_cond = df_pokemon[“Type1”] == “Poison”

poison_T2_cond = df_pokemon[“Type2”] == “Poison”

df_Poison = df_pokemon[poison_T1_cond | poison_T2_cond]

6
New cards
  1. What would you expect the output of the following code to look like? (generally, not exactly) 

sns.lmplot(data = df_pokemon, x = "Speed", y = "HP", hue = 'Legendary')

7
New cards
  1. What would you expect the output of the following code to look like? (generally, not exactly) 

sns.lmplot(data = df_pokemon, x = "Speed", y = "HP", hue = 'Legendary')

A scatterplot with speed on the x and hp on the y and one color set to pokemon who are legendary and another color for those who are not labeled legendary.

8
New cards

What would you expect the output of the following code to look like? Explain what each element of the code does and choose an appropriate label for the X axis and Y axis.

One figure with 2 histograms. 

The first is hot pink with 12 bins and shows the attack values on the X and frequency on the Y. alpha makes it 50% see through

The second is deep sky blue with 12 bins and shows only water pokemon’s attack values on the X and frequency on the Y, also 50% see through. 

A legend will say hot pink = All Pokemon and deepskyblue = Water

Xlabel should be “Attack”

Ylabel should be “frequency” 

9
New cards

Explain the difference between the functions argmax() and max()

Max finds what the max is in an array

Argmax finds where max is in an array

10
New cards

We know many different Python libraries (our import statements). Name the standard variable name (“import ____ as ??”) for each of the libraries and name the library’s common purpose

Numpy as np ← math with arrays

Pandas as pd ← dataframes, rows and columns

Seabornas sns ← statistical plots from dataframes

Matplotlib as mpl ← basic figures

Pyplot as plt ← basic figures

11
New cards

dataframe.describe()

Gives a statistical summary of numeric columns

12
New cards

dataframe.shape()

Gives the number of rows and columns in a dataframe

13
New cards

dataframe[‘column name’].unique()

Gives an array of the different values given in a column of a dataframe

14
New cards

dataframe[‘column name’].value_counts()

Tells you not just what the unique values in a column are but also how many times they were mentioned.