Informatics Practices

Inayra is writing a program using Pandas library for creating a dataframe from two dictionaries. Given below is the snippet she has developed. Help her to complete it by selecting the correct option given as under:

import ............... as pd            # Statement 1
dict = {'x': [10,25], 'y' : [32,93] }
dict 1 = {'x',: [14,56], 'y': [36,72] } 
df = pd.DataFrame (dict)
df1 = pd. ............... (dict)        # Statement 2
df2 = pd. ............... ([df, df1]) # Statement 3

1. Choose the correct option from the following for Statement 1.

    (a) pd
    (b) data
    (c) df
    (d) pandas

2. Which of the following option should be taken for Statement 2?

    (a) Series
    (b) Dataframe
    (c) DataFrame
    (d) Dictionary

3. Select the correct method from the following for Statement 3.

    (a) concat()
    (b) shape()
    (c) index()
    (d) append()

Python Data Handling

3 Likes

Answer

1. pandas

Reason — The pandas library is imported as pd using the statement import pandas as pd.

2. DataFrame

Reason — The pd.DataFrame() function is used to create a DataFrame from a dictionary.

3. concat()

Reason — The pd.concat() function is used to concatenate two or more DataFrames into a single DataFrame. In this case, it is used to concatenate df and df1 into a single DataFrame df2.

Answered By

1 Like


Related Questions