Q. Give the output for the following code:
import pandas as pd
data = [{'a': 1, 'b': 2}, {'a1': 5, 'b1': 10, 'c1': 20}]
df1 = pd.DataFrame(data, index = ['first', 'second'], columns = ['a', 'b'])
df2 = pd.DataFrame(data, index = ['first', 'second'], columns = ['a', 'b1'])
print (df1)
print (df2)
Answer :-
a b
first 1.0 2.0
second NaN NaN
a b1
first 1.0 NaN
second NaN 10.0
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )