Back to marketplace

Pandas Pt 2 (UCSD)

No description yet. This curated deck is ready for daily study.

Total cards: 14•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (14)

#1
Front (Question)

replace all of the cells in a dataframe that have value 9999 with 0

Back (Answer)

df = df.replace(9999, 0)

#2
Front (Question)

fill missing values in a dataframe with the last known value before it, or after it

Back (Answer)

df. fillna(method=’ffill’) ##forward df. fillna(method=’backfill’) ##backward

#3
Front (Question)

drop rows or columns with any NaN values

Back (Answer)

df. dropna(axis=0) ## rows df. dropna(axix=1) ## columns

#4
Front (Question)

interperolate missing values. default is linear interpolation

Back (Answer)

df.interpolate() ## fills in missing values using a linear interpolation, but there are others

#5
Front (Question)

create a dataframe with boolean values, where TRUE is set for any null values

Back (Answer)

df.isnull()

#6
Front (Question)

some common plot functions (but many more), df.plot.func()

Back (Answer)

funcs = bar(), box(), hist(), plot(), line(), pie(), scatter() ## would call differently in jupyter (w/o .plot)

#7
Front (Question)

use a magic function in jupyter to use matplotlib in jupyter

Back (Answer)

%matplotlib inline

#8
Front (Question)

get the histogram of the ratings column of the df dataframe in jupyter notebook

Back (Answer)

df.hist( column = ‘ratings’, figsize = (15,10) ) ## figsize is the size that will be plotted in the notebook

#9
Front (Question)

get the boxplot of the ratings column of the df dataframe in jupyter notebook

Back (Answer)

df.boxplot( column = ‘ratings’, figsize = (15,10) ) ## figsize is the size that will be plotted in the notebook

#10
Front (Question)

return all of the rows from a dataframe where ‘col2’ values are greater than 5

Back (Answer)

df[ df[‘col2’ > 5]

#11
Front (Question)

delete rows indexed 5 and 6 in a dataframe

Back (Answer)

df.drop[ df.index[ 5,6 ] ] or df.drop[ ‘rowName’, row2name’ ]

#12
Front (Question)

delete column ‘col2’ from a dataframe

Back (Answer)

del df [ ‘col2’ ]

#13
Front (Question)

get the mean of rows aggregated on ‘studentID’

Back (Answer)

df.groupby(‘studentID’).mean() ## groupby aggregates the rows on the column specified

#14
Front (Question)

get the count of unique rows from a set of columns in a dataframe (each different permutation of columns is unique)

Back (Answer)

df[ [ list of cols ] ].value_counts() ## optional list of columns; otherwise entire df. gives the unique col permutations and the frequency of each