Back to marketplace

Pandas Pt 1 (Wk 4 UCSD)

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

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

Card preview (24)

#1
Front (Question)

What is pandas

Back (Answer)

a library built on numpy, with flexible data structures

#2
Front (Question)

how to use the pandas library

Back (Answer)

import pandas as pd

#3
Front (Question)

What is a series in pandas

Back (Answer)

A one dimensional dict like structure (index, values), that allows for diff data types, and works w/ most numpy functions

#4
Front (Question)

how to declare a series

Back (Answer)

ser = pd.series( data=[ values], index = [indices] ) (don’t have to say data = and index =)

#5
Front (Question)

print the in dices of a series

Back (Answer)

print (ser.index)

#6
Front (Question)

retrieve data from a series at a given index ‘Bob’

Back (Answer)

ser[ ‘Bob’ ] or ser.loc[ ‘Bob’ ]

#7
Front (Question)

retrieve multiple data points in a series with index values

Back (Answer)

ser[ [ ‘bob’, ‘nancy’ ] ]

#8
Front (Question)

retrieve data from series by indexing on position

Back (Answer)

ser[ [ 1, 2, 3 ] ]

#9
Front (Question)

test if a given index is present in a series

Back (Answer)

‘bob’ in ser»_space; returns boolean

#10
Front (Question)

can you perform operations on a series, like you can with arrays?

Back (Answer)

yes. ser * 2 multiplies all values in series by 2

#11
Front (Question)

What is a dataframe

Back (Answer)

it’s like a 2d series, where indices become row names, and name of each series becomes col names

#12
Front (Question)

How do you create a dictionary with multiple sets of series, which you could then assign to a dataframe?

Back (Answer)

d = {‘one’ : pd.Series([values], index=[indices]), ‘two’ : pd.Series([values], index=[indices])}

#13
Front (Question)

create a dataframe using a dictionary of series

Back (Answer)

pd_dataframe = pd. dataframe(dict_of_series)

#14
Front (Question)

retrieve the row names from a dataframe

Back (Answer)

df.index

#15
Front (Question)

retrieve the column names from a dataframe

Back (Answer)

df.columns

#16
Front (Question)

print a dataframe in a nice tabular format

Back (Answer)

df_var (just list the var, which prints the value of the variable)

#17
Front (Question)

create a dataframe with a subset of the rows (indices)

Back (Answer)

pd.dataframe(df_var, index = [indices] )

#18
Front (Question)

create a dataframe with a subset of rows and columns

Back (Answer)

pd.dataframe(df_var, index = [indices], columns= [column_values] )

#19
Front (Question)

what happens if you create a data frame from a list of dictionaries?

Back (Answer)

the indices from each dictionary become the column names, and the rows represent each dict (opp. of when you build w/ dict. of series)

#20
Front (Question)

retrieve the values of a column from a dataframe, w/ a column name of ‘two’

Back (Answer)

df [ ‘two’ ]

#21
Front (Question)

create a third col in a df that equals the product of df columns ‘one’ and ‘two’

Back (Answer)

df[ ‘three’ ] = df[‘one’] * df[‘two’]

#22
Front (Question)

create a bool col ‘flag’ based on the values of col ‘two’ that are greater than 100

Back (Answer)

df[‘flag’] = df[‘two’] > 100

#23
Front (Question)

retrieve the value and delete a column from a df

Back (Answer)

three = df.pop(‘three’)

#24
Front (Question)

how to delete col ‘two’ from a dataframe

Back (Answer)

del df[‘two’]