Pandas Flashcards

1
Q

pd.concat()

A

(df1,df2,axis=0)

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

df.sort_values()

A

( [ ] ,ascending= , inplace=)

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

df.fillna()

A

( ‘ ‘ , inplace= )

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

df.drop()

A

( [ ] ,axis=1)

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

df.rename()

A

( columns={ } , inplace=)

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

df.merge()

A

( df2, left_on=’‘,right_on=’’, how= )

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

df.replace()

A

( { } , inplace= )

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

df.drop_duplicates()

A

([ ], keep= , inplace= )

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

df.dropna()

A

(subset= ,inplace= )

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

df.rank()

A

(ascending= , method=’dense’)

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

pd.DataFrame( )

A

“userid”: [1, 2, 3, 4, 5],
“country_id”: [46, 46, 358, 49, None]

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

fix the index

A

reset_index(drop=True)

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

df.apply()

A

(lambda x : ‘Sweden’ if x[‘name’]==’Christian’ else x[‘country’], axis=1)

or

(function,axis=1)

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

df.groupby()

A

( [ ] )

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

.agg()

A

(user_count=(‘user_count’, ‘count’))

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

make df[‘signup_date’] to month

A

.dt.month

17
Q

.rolling()

A

(window=7, min_periods=1).sum()

18
Q

remove time in datetime

A

df.normalize()

19
Q

row_number

A

df.reset_index(drop=True).index + 1

20
Q

+ pd.to_timedelta()

A

(3, unit=’D’)

21
Q

unique()

A

tar fram alla columner