Back to marketplace

Pandas Pt 3 (UCSD)

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

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

Card preview (15)

#1
Front (Question)

how do you stack dataframes left and right vertically

Back (Answer)

pd.concat( [ left, right] ) ## will end up w/ 1 df w/ all of the unique cols of the original, and new rows

#2
Front (Question)

how do you do an inner join on dataframes left and right (but columns repeated)

Back (Answer)

pd.concat( [ left, right] ), axis =1, join=’inner’ ) ## end up repeating duplicate columns

#3
Front (Question)

what’s another means of vertical stacking left and right dataframes, using append?

Back (Answer)

left.append(right)

#4
Front (Question)

how do you merge left and right like a join, w/o repeating the columns

Back (Answer)

pd.merge (left, right, how=’inner’ )

#5
Front (Question)

merge movies and tags dataframe, on movie ID, inner join

Back (Answer)

t = movies.merge(tags, on=’movieId’, how=’inner’)

#6
Front (Question)

get the first five rows of df that match bool filter1 and bool filter2

Back (Answer)

df[ filter1 & filter2 ][ :5 ]

#7
Front (Question)

split the string values in col ‘city’ in a df using a ‘_’ separator

Back (Answer)

df [‘city’].str.split(‘_’) ## replaces the values in that column w/ lists separated on

#8
Front (Question)

check if any value in the city col of df contains the substring ‘2’

Back (Answer)

df[ ‘city’ ].str.contains(‘2’)

#9
Front (Question)

df.str.func() to replace substring

Back (Answer)

df.str.replace( subToReplace, replacementSub)

#10
Front (Question)

df.srt function to return the values matched by a regex

Back (Answer)

df[ colName ].str.extract( ‘ regex ‘ ) ## looks like it returns a sliced df, or a series

#11
Front (Question)

use split to break values out into new columns

Back (Answer)

df.str.split( separator, expand = TRUE )

#12
Front (Question)

what is unix / posix / epoch

Back (Answer)

counts the number of seconds since 1970 as per UTC time zone

#13
Front (Question)

what is datatime64[ns]

Back (Answer)

standard python format you can use to compare times ## df[‘time’] > ‘2020-01-01’

#14
Front (Question)

convert from unix time to datetime64 format

Back (Answer)

pd.to_datetime(tags[ ‘timestampCol’ ], unit = ‘s’ ) ## unit refers to seconds

#15
Front (Question)

sort values by a parsed time column in a df

Back (Answer)

df.sort_values(by = ‘parsedTimeCol’, ascending = True)