Random pandas info Flashcards

1
Q

How do you get an array of the unique values in a specific column?

A

df[‘Column’].unique()

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

How do you get the number of each unique value in a specific column?

A

df[‘Column’].value_counts()

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

How do you get quick stats for a DataFrame?

A

df.describe()

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

How do you retrieve the values of a Series s?

A

s.values

outputs ndarray

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

What happens when you call s.index on a Series s?

A

Gives you a RangeIndex object, it’s a generator. Turns into a list with the numbers it generates if you call list() on it

If you call it on a Series without an integer index, returns an Index object (basically just a list)

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

How do you set a name for a Series s?

A

s.name = ‘name’

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

how do you set a name for the index of Series s?

A

s.index.name = ‘name’

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

What happens if you construct a Series using a list that has a float in it?

A

Every value in the series will be a float

Series are homogenous

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

What happens if you initiate Series s with a dict?

e.g. s = Series(dict)

A

Keys are Series index

Values are Series values

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

How do you multiply all values of a Series s by 2?

A

s * 2

Series work like numpy arrays

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

What happens if you call a numpy universal func on a Series?

A

Works as if it were an ndarray

Series work like numpy arrays

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

How do you generate a cumulative sum?

A

Hypothesis: I’ll remember this easy cause it just clicked for me

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

How do you check if a value ‘X’ is in a Series s?

A

‘X’ in s

Returns boolean

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