notebooks Flashcards

1
Q

class

A

can be thought of as a type. it determines what you can do with a variable and what operators you can use with this class. it will define what all operators mean when applied to objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

object

A

an instance of a class. every variable in your program is in fact an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

type() function

A

tells us about what is the class of this object. it also works for functions and methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

encapsulation

A

groups the variables and function that are highly related.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

abstraction

A

makes the interface of an object simpler and reduces the impact of change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

inheritance

A

mechanism to reduce redundant code. functions or states that are shared among objects, can be reused by inheriting from classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

polymorphism

A

something occurs in several different forms. eg., you can call the same functional call payout_salary() based on the different object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

python list

A

an object of class list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

pandas dataframes

A

like Excel sheets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

constructor

A

a function that helps you create new objects of this class. each class usually has a constructor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

instance method

A

a function that applies to a object. you call this function like this variable.method().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

txt.lower()

A

a function that puts a string variable in lowercase.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

txt.upper()

A

a function that puts a string variable in uppercase. the equivalent of having a function: def upper(string) and calling upper(txt).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

txt.isalpha()

A

returns True if all characters in the string are in the alphabet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

txt.strip()

A

returns a trimmed version of the string. eg. txt.strip(‘I’) removes ‘I’ from I am sterdam.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

class method

A

it is called by using classname.method(). eg. for datetime.today(), datetime is the name of the class and today is the name of the method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

pandas

A

a very popular python library, specialized in handling spreadsheet data. like a true panda, it handles data by chewing it relentlessly and effortlessly. the name comes from panel datas.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

read_csv()

A

a function from the module pandas, noted as pandas.read_csv(). it is used to read data from a text file where each line is a row of our spreadsheet. columns are separated by a character, eg. ‘\t’. in this case, write sep= ‘\t’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

df

A

an object with the class DataFrame. it has 360 methods you can call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

head()

A

a method that can be called to display the first N rows of the spreadsheet by typing df.head().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

df.types

A

an attribute of the object df. it is a value and indicates the type of data in each column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

df[condition]

A

only shows the rows where the condition is True. a condition can be eg. df[‘item_name’ == ‘Izze’. it is true for rows where the value in columns item_name is equal to the string ‘Izze’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

apply method

A

applies a function to each element of a column. the results overwrite the current data in the column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

groupby

A

a method of df. it groups all rows with the same value for a given variable, eg. item_name. df.groupby(‘item_name’) is an object of class pd.DataFrameGroupBy. it has 134 methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

sum

A

a method of df.groupby(‘item_name’). it groups all rows by item_name. it is a new spreadsheet with the same column and one row per item_name value. for each column it aggregates the value using sum() (sums all values).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

sort_values

A

a method used to sort the rows of a spreadsheet according to the values in a column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

describe

A

a method of the object by_order. it gives you basic statistics, per column.

28
Q

encapsulation

A

refers to data security.

29
Q

abstraction

A

hidden complexity.

30
Q

polymorphism

A

code reusability through the same method call but with a different response.

31
Q

inheritance

A

code reusability through subclasses to inherit characteristics of parents.

32
Q

‘self’

A

used to represent the instance of the class itself. by convention, the argument is named self, although you can name it differently if you wish. the purpose is to allow methods to access and modify the attributes and methods of the instance to which they belong. it refers to the initialising of an object.

33
Q

’-‘ for two objects from class datetime

A

works as ‘how long between those two dates and times?’

34
Q

’+’ for a datetime object and timedelta object

A

works as ‘what time would it be if we add … to a date?’

35
Q

data granularity

A

a measure of the level of detail in a data structure.

36
Q

pd.cut

A

a function from the module pd. it takes a list of values and the limits of our categories.

37
Q

sample method

A

returns a random sample from the dataframe.

38
Q

count()

A

counts the number of rows in each category.

39
Q

.plot.pie method

A

used to plot a pie chart.

40
Q

concat method

A

used to add dataframes together.

41
Q

axis

A

using the keys from the column or rows to concatenate. by default, we concatenate rows by matching columns.

42
Q

inner join

A

only takes as result the subset of both data frames that have matching indexes.

43
Q

pivoting

A

the reorganization of a data frame by means of aggregation of selected columns values as rows in the new data frame.

44
Q

NaN

A

stands for Not a Number, but means missing number. different forms exist based on the data type, eg. NaT.

45
Q

None

A

a value that there is no object, usually the return of a function (there was no return value). None is not the same as 0, False, or an empty object.

46
Q

fillna()

A

a function that can be used to replace missing values.

47
Q

left_on

A

refers to a parameter used in the merging or joining of two DataFrames. used to specify the column or columns from the left DataFrame (the one whose rows you want to keep all of) that will be used for the merge operation.

48
Q

isna() function

A

tells you whether values have been set to NaN and returns True or False:

49
Q

notna()

A

a method used to identify non-missing values within a Series or DataFrame. It returns True or False indicating whether each element in the Series or DataFrame is not missing.

50
Q

fillna()

A

a method used to fill missing (NaN) values in a DataFrame or Series with a specified value or using a specified method.

51
Q

np.nan

A

represents a missing or undefined value in numpy.

52
Q

drop() function

A

a method used to remove rows or columns from a DataFrame.

53
Q

loc function

A

used for selecting data from a DataFrame and is label-based. you use the index and column names to select data.

54
Q

iloc function

A

used for selecting data from a DataFrame and is integer-based. you use the integer positions to select data. in df.iloc[0, 1], 0 indicates the row and 1 indicates the column.

55
Q

duplicated()

A

a function used to identify duplicate rows in a DataFrame. it returns True or False.

56
Q

is_unique

A

shows whether the indexes in a dataframe are unique.

57
Q

matlab

A

used to build figures in Python on a canvas. the canvas has subplots that can contain x and y-axes.

58
Q

set_facecolor(‘color’)

A

can make the canvas on a figure a specified colour.

59
Q

np.linspace function

A

it is used to create an array of evenly spaced numbers over a specified range. results in a number of points on the figure we printed.

60
Q

plt.plot

A

a function used to create a basic line plot. plot(x3, np.sin(x), color = red) indicates a red sinus figure which uses x3 as the x-values.

61
Q

plt.axes

A

a function used to create or modify an axes object within a figure. an axes object represents an individual plot within a figure.

62
Q

plt.xlim/plt.ylim

A

a function used to set the limits for the x- or y-axis of a plot. specifically, it sets the minimum and maximum values for the x- or y-axis range. eg. plt.xlim(0, 10) sets the minimum limit of the x-axis to 0 and the maximum limit to 10.

63
Q

set_xlabel/set_ylabel

A

changes the label of the axis. eg., ax4.set_xlabel(‘x label’)

64
Q

set_title

A

changes the title of the figure. eg,. ax4.set_title(‘graph’)

65
Q

legend()

A

adds a legend to the figure. eg., ax4.legend()