Data Science Tool Box - 2 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is an iterable and an iterator?

A

An iterable is an object that can return an iterator, while an iterator is an object that keeps state and produces the next value when you call next() on it.

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

What does the enumerate () do?

A

enumerate() returns an enumerate object that produces a sequence of tuples, and each of the tuples is an index-value pair.

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

z1 = zip(mutants,powers)

result1, result2 = zip(*z1)

A

This code zips and then unzips the lists back to their original list form (result1, result2 = zip(*z1))

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

What does the argument chunksize in the read_csv() do?

A

Sometimes, the data we have to process reaches a size that is too much for a computer’s memory to handle. This is a common problem faced by data scientists. A solution to this is to process an entire data source chunk by chunk, instead of a single go all at once.

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

The following list has been pre-loaded in the environment.

doctor = [‘house’, ‘cuddy’, ‘chase’, ‘thirteen’, ‘wilson’]

How would a list comprehension that produces a list of the first character of each string in doctor look like?

A

The list comprehension is [doc[0] for doc in doctor] and produces the list [‘h’, ‘c’, ‘c’, ‘t’, ‘w’].

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