lecture python Flashcards
dictionary
a list where the index can be (almost) anything, eg. a string or a number. the index is called a key. what is available at this key is called a value.
built-in functions
functions that are already built. Most of what you want to do with a list already exists as a function, eg. sum(), max(), and min().
functions
lead to (1) less code to write, (2) less code to debug and modify, and (3) less code to read.
defining
means (1) the name of the function, (2) what arguments it receives, and (3) what value it returns.
calling
means (1) using the function, (2) providing arguments, and (3) getting the return value.
modules
contain functions, eg. math module.
yfinance
module that gathers stock information from Yahoo Finance.
mplfinance
module that creates graphs from financial data.
numpy-financial
a collection of financial and accounting functtions.
keys() method
can be used to make a list of the keys in a dictionary. eg., car_info1.keys()
abs()
a function that returns the absolute value of an argument. eg., -5 returns 5.
dataframe.dtypes
indicates the type of data in each column of a dataframe.
head() method
shows the first x amount of columns in a dataframe, as specified by the argument.
apply() method
applies a function to every element of a column or dataframe, as specified in the argument.
plot.bar
a method used to plot a bar graph. barh, gives a horizontal bar graph.
_
gets rid of the display at the top of a graph. eg. _ = …
describe() method
used to generate descriptive statistics for a dataframe.
bins
specifies the number of intervals into which the data will be divided in eg. a histogram.
pd.cut
a function from the pd module that takes a list of values.
sample method
returns a random sample from a dataframe.
upper() method
a method that converts a string value into uppercase.
strip() method
method used to remove leading and trailing spaces whitespaces.
isalpha() method
a method to check if all the characters in a string are alphabetic. It returns True if all characters in the string are alphabetic (letters), otherwise it returns False.
80/20 rule
indicates that 80% of your time is spent shaping and cleaning your data and 20% is spent visualising data.
slicing
data can be seen as a cube with multiple dimensions. with slicing, we only want one part of the data cube.
dice
selects specific values of multiple dimensions to produce a new subcube.
pd.series()
a method that creates a series object. it is capable of holding any data type and similar to a list, but with more features.