Quiz: Joining in pandas
Quiz yourself on joining in pandas.
1
Look at the two DataFrames df1
and df2
below:
a b c
0 1 2 3
1 2 2 4
2 2 1 3
and
a b d
0 10 20 30
1 20 20 40
2 20 10 30
We want to concatenate the two DataFrames into one. What will be the output of the following command?
pd.concat([df1, df2], ignore_index = True, join = 'inner')
A)
a b
0 1 2
1 2 2
2 2 1
3 10 20
4 20 20
5 20 10
B)
a b
0 1 2
1 2 2
2 2 1
0 10 20
1 20 20
2 20 10
C)
a b c d
0 1 2 3 NaN
1 2 2 4 NaN
2 2 1 3 NaN
3 10 20 NaN 30
4 20 20 NaN 40
5 20 10 NaN 30
D)
a b c d
0 1 2 3 NaN
1 2 2 4 NaN
2 2 1 3 NaN
0 10 20 NaN 30
1 20 20 NaN 40
2 20 10 NaN 30
Question 1 of 40 attempted
Get hands-on with 1400+ tech skills courses.