1/13
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Given the following array X, identify what element is in position 4
X = np.array([2, 4, 5, 6, 12, 5, 6])
12
What Python call would you make to find the location of 12 in array X?
np.where(X == 12)
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]
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]
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]
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')
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.
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”
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
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
dataframe.describe()
Gives a statistical summary of numeric columns
dataframe.shape()
Gives the number of rows and columns in a dataframe
dataframe[‘column name’].unique()
Gives an array of the different values given in a column of a dataframe
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.