A _______________ is a two-dimensional labelled data structure .
1.DataFrame
2.Series
3.List
4.None of the above
DF1.loc[ ] method is used to ______ # DF1 is a DataFrame
1.Add new row in a DataFrame ‘DF1’
2.To change the data values of a row to a particular value
3.Both of the above
4.None of the above
Display first row of dataframe ‘DF’
1.print(DF.head(1))
2.print(DF[0 : 1])
3.print(DF.iloc[0 : 1])
4.All the above
If the following statement return (5, 3) it means _____ >>> DF.shape #DF is a DataFrame object
1.DataFrame DF has 3 rows 5 columns
2.DataFrame DF has 5 rows 3 columns
3.DataFrame DF has 3 rows 5 rowlabels
4.None of the above
In given code dataframe ‘D1’ has _____ rows and _____ columns. import pandas as pd S1 = pd.Series([1, 2, 3, 4], index = ['a', 'b','c','d']) S2 = pd.Series([11, 22, 33, 44], index = ['a', 'bb','c','dd']) D1 = pd.DataFrame([S1,S2])
1. 2, 4
2.4, 6
3. 4, 4
4. 2, 6
The following code create a dataframe named ‘D1’ with ______ rows. import pandas as pd LoD = [{'a':10, 'b':20}, {'a':5, 'b':10, 'c':20}] D1 = pd.DataFrame(LoD)
1.0
2.1
3.2
4.3
The following statement will _________ df = df.drop(['Name', 'Class', 'Rollno'], axis = 1) #df is a DataFrame object
1.delete three columns having labels ‘Name’, ‘Class’ and ‘Rollno’
2. delete three rows having labels ‘Name’, ‘Class’ and ‘Rollno’
3.delete any three columns
4. return error
The parameter axis=’index’ of rename( ) function is used to specify that the __
1.row and column label is to be changed
2. column label is to be changed
3.row label is to be changed
4.None of the above
The ________________parameter of append() method in DataFrame may be set to True, when we do not want to use row index labels.
1.ignore_index_val
2. ignore_index_value
3. ignore_index
4.None of the above
What we are doing in the following statement? dF1=dF1.append(dF2) #dF1 and dF2 are DataFrame object
1.We are appending dF1 in dF2
2.We are appending dF2 in dF1
3.We are creating Series from DataFrame
4.None of the above
When we create DataFrame from List of Dictionaries, then dictionary keys will become ___________
1.Column labels
2.Row labels
3.Both of the above
4.None of the above
Which of the following attribute of DataFrame display all the values from DataFrame?
1.values
2.Values
3.. val
4. Val
Which of the following function is used to load the data from the CSV file into a DataFrame?
1.read.csv( )
2.readcsv( )
3.read_csv( )
4.Read_csv( )
Which of the following parameter is used to specify row or column in rename function of DataFrame?
1.rowindex
2.colindex
3.Both of the above
4.index
Write statement to transpose dataframe DF.
1.DF.T
2.DF.transpose
3.DF.t
4.DF.T( )
______________ parameter is used in append( ) function of DataFrame to get the column labels in sorted order.
1.sorted .
2.sorter
3.sort
4.None of the above
D1[ : ] = 77 , will set __________ values of a Data Frame ‘D1’ to 77.
1.Only First Row
2.Only First Column
3.all
4.None of the above
DataFrame created from single Series has ____ column.
1.1
2.2
3.n (Where n is the number of elements in the Series)
4.None of the above
DataFrame.loc[ ] is an important method that is used for ____________ with DataFrames
1.Label based indexing
2.Boolean based indexing
3.Both of the above
4.All the above
Display last two rows from dataframe ‘DF’
1.print(DF[-2 : -1])
2.print(DF.iloc[-2 : -1])
3.print(DF.tail(2))
4.All the above
Following statement will display ___________ rows from DataFrame ‘DF1’. >>> DF1.head()
1.all
2.2
3.3
4.5
If the DataFrame has more than one row with the same label, then DataFrame.drop( ) method will delete _____
1.first matching row from it.
2.all the matching rows from it
3. last matching row from it.
4.Return Error
In DataFrame, by default new column added as the _____________ column
1.First (Left Side)
2.Second
3.Last (Right Side)
4.Random
In given code dataframe ‘D1’ has _____ rows and ______ columns.
1.3, 3
2.3, 2
3. 2, 3
4.None of the above
In given code dataframe ‘D1’ has ________ rows and _______ columns. import pandas as pd LoD = [{‘a’:10, ‘b’:20}, {‘a’:5, ‘b’:10, ‘c’:20},{‘a’:7, ‘d’:10, ‘e’:20}] D1 = pd.DataFrame(LoD)
1.3, 3
2. 3, 4
3.3, 5
4.None of the above
In Pandas _______________ is used to store data in multiple columns.
1.Series
2. DataFrame
3.Both of the above
4.None of the above
In the following statement, if column ‘Rollno’ already exists in the DataFrame ‘D1’ then the assignment statement will __________ D1['Rollno'] = 11
1.Return error
2.Change all values of column Roll numbers to 11
3.Add new column
4.None of the above
In the following statement, if column ‘Rollno’ already exists in the DataFrame ‘D1’ then the assignment statement will __________ D1['Rollno'] = [1, 2] #There are only three rows in DataFrame D1'
1.Return error
2.Replace the already existing values.
3.Add new column
4.None of the above
In the following statement, if column ‘Rollno’ already exists in the DataFrame ‘D1’ then the assignment statement will _____________ D1['Rollno'] = [1,2,3] #There are only three rows in DataFrame D1'
1.Return error
2.Replace the already existing values.
3.Add new column
4.None of the above
Parameters of read_csv( ) function is _____
1.sep
2.Header
3.Both of the above
4.None of the above
The append() method of DataFrame can also be used to append ____________to a DataFrame
1.Series
2.Dictionary
3.Both of the above
4.None of the above
The default value for sep parameter is ____
1.comma
2.semicolon
3.space
4.None of the above
The following code create a dataframe named ‘D1’ with ___________ columns. import pandas as pd LoD = [{‘a’:10, ‘b’:20}, {‘a’:5, ‘b’:10, ‘c’:20}] D1 = pd.DataFrame(LoD)
1.1
2.2
3.3
4.4
The following code create a dataframe named ‘D1’ with _______________ columns.
1.1
2.2
3.3
4.4
The following statement is __________ >>> DF=DF.rename({‘Maths’:’Sub1′,‘Science’:’Sub2′}, axis=’index’) #DF is a DataFrame
1.altering the row labels
2.altering the column labels
3.altering the row and column labels (both)
4.Error
The following statement will display ________ rows of DataFrame ‘DF’ print(df.loc[[True, False,True]])
1.1
2.2
3.3
4.4
The following statement will return the column as a _______ >>> DF.loc[: , 'Name'] #DF is a DataFrame object
1.DataFrame
2.Series
3.List
4.Tuple
The following two statement will return _______________ >>> DF.loc[:,'Name'] #DF is a DataFrame object >>> DF['Name'] #DF is a DataFrame object
1.Same Output
2.Name column of DataFrame DF
3.Both of the above
4.Different Output
To delete a column, the parameter axis of function drop( ) is assigned the value ____
1.0
2.1
3.2
4.3
To delete a row, the parameter axis of function drop( ) is assigned the value __
1.0
2.1
3.2
4.3
Transpose the DataFrame means _______
1.Row indices and column labels of the DataFrame replace each other’s position
2.Doubling the number of rows in DataFrame
3.Both of the above
4.None of the above
We can add a new row to a DataFrame using the _____________ method
1.rloc[ ]
2. iloc[ ]
3.. loc[ ]
4.None of the above
We can create DataFrame from _____
1. Numpy arrays
2.List of Dictionaries
3.Dictionary of Lists
4.All the above
We can merge/join only those DataFrames which have same number of columns
1.True
2.False
3.Error
4.None of the above
We can use the ______ method to merge two DataFrames
1.merge( )
2.join( )
3. append( )
4.drop( )
What value should be given to axis parameter of rename function to alter column name?
1.column
2.columns
3.index
4.None of the above
What will happen if in the rename( ) function we pass only a value for a row label that does not exist?
1.it returns an error.
2.matching row label will not change .
3.the existing row label will left as it is.
4.None of the above
When we create DataFrame from Dictionary of List then Keys becomes the ______
1.Row Labels
2.Column Labels
3.Both of the above
4.None of the above
When we create DataFrame from Dictionary of List then List becomes the __________
1.Row Labels
2.Column Labels
3.Values of rows
4.None of the above
When we create DataFrame from List of Dictionaries, then number of columns in DataFrame is equal to the _
1.maximum number of keys in first dictionary of the list
2. maximum number of different keys in all dictionaries of the list
3.maximum number of dictionaries in the list
4.None of the above
When we create DataFrame from List of Dictionaries, then number of rows in DataFrame is equal to the _______
1.maximum number of keys in first dictionary of the list
2.maximum number of keys in any dictionary of the list
3. number of dictionaries in the list
4.None of the above
Which library is to be imported for creating DataFrame?
1.Python
2.DataFrame
3.Pandas
4.Random
Which method is used to change the labels of rows and columns in DataFrame?
1.change( )
2.rename( )
3.. replace( )
4.None of the above
Which method is used to delete row or column in DataFrame?
1.delete( )
2.del( )
3. drop( )
4.None of the above
Which of the following are ways of indexing to access Data elements in a DataFrame?
1.Label based indexing
2.Boolean Indexing
3.All of the above
4.None of the above
Which of the following attribute of DataFrame display the dimension of DataFrame
1.shape
2.size
3.dimension
4.values
Which of the following attribute of DataFrame is used to display column labels?
1.columns
2.index
3.dtypes
4.values
Which of the following attribute of DataFrame is used to display data type of each column in DataFrame?
1.Dtypes
2.DTypes
3.dtypes
4.datatypes
Which of the following attribute of DataFrame is used to display row labels?
1.columns
2.index
3.dtypes
4.values
Which of the following function display the last ‘n’ rows from the DataFrame?
1.head( )
2.tail( )
3.Tail( )
4.None of the above
Which of the following function is used to create DataFrame?
1.DataFrame( )
2.NewFrame( )
3.CreateDataFrame( )
4.None of the above
Which of the following is used to display first 2 rows of DataFrame ‘DF’?
1.DF.head( )
2.DF.header(2)
3.DF.head(2)
4.None of the above
Which of the following is used to give user defined column index in DataFrame?
1. index
2.column
3.columns
4.colindex
Which of the following statement is Transposing the DataFrame ‘DF1’?
1.DF1.transpose
2.DF1.T
3.DF1.Trans
4.DF1.t
Which property of dataframe is used to check that dataframe is empty or not?
1. isempty
2.IsEmpty
3.empty
4.Empty
Write a statement to delete column labelled as ‘R1’ of DataFrame ‘DF’..
1.DF= DF.drop(‘R1’, axis=0)
2.DF= DF.del(‘R1’, axis=0)
3.DF= DF.drop(‘R1’, axis=0, row = ‘duplicate’)
4.None of the above
Write statement to display the column labels of DataFrame ‘DF’
1.DF.Column
2.DF.column
3.DF.columns
4.DF.Columns
Write statement to display the data types of each column of dataframe ‘DF’.
1.DF.types( )
2.DF.dtypes
3.DF.dtypes( )
4.All the above
Write statement to display the dimension of dataframe ‘DF’.
1.DF.dim
2.DF.ndim
3.DF.dim( )
4.None of the above
Write statement to display the row labels of ‘DF’.
1. DF.Index
2.DF.index( )
3.DF.index
4.DF.row_index
Write the code to remove duplicate row labelled as ‘R1’ from DataFrame ‘DF1’
1.DF1 = DF1.drop(‘R1’, axis = 0)
2.DF1 = DF1.drop(‘R1’, axis = 1)
3.DF1 = DF1.del(‘R1’, axis = 0)
4.DF1 = DF1.del(‘R1’, axis = 1)
Write the output of the statement >>>df.empty , if df has the following structure: Name Class Rollno 0 Amit 6 1 1 Anil 7 2 2 Ravi 8 3
1.True
2.False
3.Error
4.None of the above
Write the output of the statement >>>df.shape , if df has the following structure. Name Class Rollno 0 Amit 6 1 1 Anil 7 2 2 Ravi 8 3
1.(3, 4)
2.(4, 3)
3. (3, 3)
4.All the above
Write the output of the statement >>>df.size , if df has the following structure: Name Class Rollno 0 Amit 6 1 1 Anil 7 2 2 Ravi 8 3
1.9
2.12
3.6
4.None of the above
_____ parameter of append( ) method may be set to True when we want to raise an error if the row labels are duplicate.
1.verify_integrity
2.verifyintegrity
3.verify.integrity
4.None of the above
_________ data Structure has both a row and column index.
1. List
2.Series
3.DataFrame
4.None of the above