reshape data Flashcards

1
Q

con que metodo pandas conseguirias lo siguiente?

A

con melt

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

como conseguirias lo siguiente en un dataframe? (Spread rows into columns)

A

con df.pivot(columns=’var’, values=’val’)

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

como conseguirias lo siguiente ? (Append rows of DataFrames)

A

con pd.concat([df1,df2])

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

como conseguirias los siguiente ?? (Append columns of DataFrames)

A

con pd.concat([df1,df2], axis=1)

otros argumentos mirar la foto

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

Order rows by values of a column (low to high).

A

df.sort_values(‘mpg’)

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

Order rows by values of a column (high to low)

A

df.sort_values(‘mpg’,ascending=False)

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

Rename the columns of a DataFrame

A

df.rename(columns = {‘y’:’year’})

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

Sort the index of a DataFrame

A

df.sort_index()

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

Reset index of DataFrame to row numbers, moving index to columns.

A

df.reset_index()

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

Drop columns from DataFrame

A

df.drop(columns=[‘Length’,’Height’])

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