My Data Science professor posted some code that we are supposed to follow for homework. Here are part of it:
def create_compare_df() -> pd.DataFrame:
"""Generate comparison dataframe for lists.
Returns
--------
pd.Dataframe
Pandas data frame containing time metrics for selection sort algorithm --------
"""
compare: dict = {
"array_length" : [512, 1024, 2048, 4096, 8192],
"sorted_time": [],
"binarysearch_time": [],
"linearsearch_time": [],
}
for i in compare["array_length"]:
.........
I do not know what is the "Compare: dict = ..." part, and wehn I tested the code, it says "compare" is not defined...
I have never seen dictionary defined as above. any idea?
Thanks, Philip
: dict.compare = { ... }that should define the variable.print(compare)inside the function? The variable is local, so you can't print it outside the function.