Random pandas info Flashcards
How do you get an array of the unique values in a specific column?
df[‘Column’].unique()
How do you get the number of each unique value in a specific column?
df[‘Column’].value_counts()
How do you get quick stats for a DataFrame?
df.describe()
How do you retrieve the values of a Series s?
s.values
outputs ndarray
What happens when you call s.index on a Series s?
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 do you set a name for a Series s?
s.name = ‘name’
how do you set a name for the index of Series s?
s.index.name = ‘name’
What happens if you construct a Series using a list that has a float in it?
Every value in the series will be a float
Series are homogenous
What happens if you initiate Series s with a dict?
e.g. s = Series(dict)
Keys are Series index
Values are Series values
How do you multiply all values of a Series s by 2?
s * 2
Series work like numpy arrays
What happens if you call a numpy universal func on a Series?
Works as if it were an ndarray
Series work like numpy arrays
How do you generate a cumulative sum?
Hypothesis: I’ll remember this easy cause it just clicked for me
How do you check if a value ‘X’ is in a Series s?
‘X’ in s
Returns boolean