non-ML MISC Flashcards
Syntax to flatten a list of lists (without using itertools)
reduce(lambda x,y: x+y, list_of_lists)
What is “floor division” and the syntax for doing it?
Like regular division, but rounds down to nearest whole number.
Example: 8 // 3 returns 2
Syntax to check whether a variable is of a particular type
isinstance(my_var, some_type)
What does .strip() do?
Removes leading and trailing spaces (including “\n”s)
What string method removes leading and trailing spaces (including “\n”s)?
.strip()
Syntax to stop printing when encounter a particular substring?
print(some_text, end=’ ‘)
Syntax to find first index of a substring within a string?
string.find(substring)
Syntax to find first appearance of a value within a list?
my_list.index(my_value, start_position)
What to use instead of .isnull() and .notnull()?
.isna() and .notna()
What is an ML model?
Simply a function that takes observations as inputs and outputs some kind of prediction (e.g., values of a DV) or other outcome (e.g., cluster labels)