167 solutions available
Question 1Assertion (A). To use the Pandas library in a Python program, one must import it.Reasoning (R). The only alias name that can be used with...
Question 2Assertion. A series is a 1D data structure which is value-mutable but size-immutable.Reason. Every time you change the size of a series...
Question 3Assertion. A dataframe is a 2D data structure which is value mutable and size mutable.Reason. Every change in a dataframe internally...
Question 4Assertion. A dataframe is value mutable and size-mutable.Reason. All changes occur in-place in a dataframe.Both A and R are true and R is...
Question 5Assertion. A series object stores values of homogeneous types.Reason. Even if values appear to be of different types, internally they are...
Question 6Assertion. Arithmetic operations on two series objects take place on matching indexes.Reason. Non-matching indexes are removed from the...
Question 7Assertion. Arithmetic operations on two series objects take place on matching indexes.Reason. For non-matching indexes of series objects in...
Question 8Assertion. While changing the values of a column in a dataframe, if the column does not exist, an error occurs.Reason. If values are...
Question 9Assertion. .loc() is a label based data selecting method to select a specific row(s) or column(s) which we want to select.Reason. .iloc()...
Question 10Assertion. DataFrame has both a row and column index.Reason. A DataFrame is a two-dimensional labelled data structure like a table of...
Question 1What is the use of Python Pandas library ?
Question 2Name the Pandas object that can store one dimensional array like object and can have numeric or labelled indexes.
Question 3Can you have duplicate indexes in a series object ?
Question 4What do these attributes of series signify ?(i) size(ii) itemsize(iii) nbytes
Question 5If S1 is a series object then how will len(S1) and S1.count() behave ?
Question 6What are NaNs ? How do you store them in a data structures ?
Question 7True/False. Series objects always have indexes 0 to n -1.
Question 8What is the use of del statement ?
Question 9What does drop() function do ?
Question 10What is the role of inplace argument in rename() function.
Question 1Pandas is a popular data-science library of Python.
Question 2A series is a Pandas data structure that represents a 1 D array like object.
Question 3A DataFrame is a Pandas data structure that represents a 2 D array like object.
Question 4You can use numpy.NaN for missing data.
Question 5To specify datatype for a Series object, dtype argument is used.
Question 6The len() function on Series object returns total elements in it including NaNs.
Question 7The count() function on Series object returns only the count of non-NaN values in it.
Question 8Series is value mutable.
Question 9Series is not size mutable.
Question 10DataFrame is size mutable as well as value mutable.
Question 11In a DataFrame, Axis = 1 represents the column elements.
Question 12To access values using row labels you can use DF.loc .
Question 13To access individual value, you can use DF.at using row/column index labels.
Question 14To access individual value, you can use DF.iat using row/column integer position.
Question 15The rename() function requires inplace argument to make changes in the original dataframe.
Question 1Which of the following statement will import pandas library ?Import pandas as pdimport Pandas as pyimport pandas as pdimport panda as pd
Question 2To create an empty Series object, you can use :pd.Series(empty)pd.Series(np.NaN)pd.Series( )all of these
Question 3To specify datatype int16 for a Series object, you can write :pd.Series(data = array, dtype = int16)pd.Series(data = array, dtype =...
Question 4To get the number of dimensions of a Series object, ............... attribute is displayed.indexsizeitemsizendim
Question 5To get the size of the datatype of the items in Series object, you can display ............... attribute.indexsizeitemsizendim
Question 6To get the number of elements in a Series object, ............... attribute may be used.indexsizeitemsizendim
Question 7To get the number of bytes of the Series data, ............... attribute is displayed.hasnansnbytesndimdtype
Question 8To check if the Series object contains NaN values, ............... attribute is displayed.hasnansnbytesndimdtype
Question 9To display third element of a Series object S, you will write ............... .S[:3]S[2]S[3]S[:2]
Question 10To display first three elements of a Series object S, you may write ............... .S[:3]S[3]S[3rd]all of these
Question 11To display last five rows of a Series object S, you may write ............... .head()head(5)tail()tail(5)
Question 12Which of the following statement is wrong ?We can't change the index of the seriesWe can easily convert the list, tuple, and dictionary...
Question 13What type of error is returned by the following statement ?import pandas as pa pa.Series([1, 2, 3, 4], index = ['a', 'b', 'c'])Value...
Question 14What will be the output of the following code ?import pandas as pd myser = pd.Series([0, 0, 0]) print(myser)0 00 00 00 10 10 20 01 02 00...
Question 15To display last five rows of a series object 'S', you may write :S.Head()S.Tail(5)S.Head(5)S.tail()
Question 16Missing data in Pandas object is represented through :NullNoneMissingNaN
Question 17In Python Pandas, while performing mathematical operations on series, index matching is implemented and all missing values are filled in...
Question 18Given a Pandas series called Sequences, the command which will display the first 4 rows is ..................
Question 19Which of the following statement is wrong in context of DataFrame ?Two dimensional size is MutableCan Perform Arithmetic operations on...
Question 20Which of the following is a two-dimensional labelled data structure of Python ?RelationDataFrameSeriesSquare
Question 21When we create a DataFrame from a list of Dictionaries the columns labels are formed by the :Union of the keys of the...
Question 22If a DataFrame is created using a 2D dictionary, then the indexes/row labels are formed from ............... .dictionary's valuesinner...
Question 23If a dataframe is created using a 2D dictionary, then the column labels are formed from ............... .dictionary's valuesinner...
Question 24Which of the following can be used to specify the data while creating a DataFrame ?SeriesList of DictionariesStructured ndarrayAll of these
Question 25The axis 0 identifies a DataFrame's ............... .rowscolumnsvaluesdatatype
Question 26The axis 1 identifies a DataFrame's ............... .rowscolumnsvaluesdatatype
Question 27To get the number of elements in a dataframe, ............... attribute may be used.sizeshapevaluesndim
Question 28To get NumPy representation of a dataframe, ............... attribute may be used.sizeshapevaluesndim
Question 29To get a number representing number of axes in a dataframe, ............... attribute may be used.sizeshapevaluesndim
Question 30Which attribute is not used with DataFrame ?SizeTypeEmptyColumns
Question 31To get the transpose of a dataframe D1, you can write ............... .D1.TD1.TransposeD1.SwapAll of these
Question 32To extract row/column from a dataframe, ............ function may be used.row()column()loc()All of these
Question 33To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe DF, you can write ............... .DF.loc[6:9,...
Question 34To change the 5th column's value at 3rd row as 35 in dataframe DF, you can write ............... .DF[4, 6] = 35DF[3, 5] = 35DF.iat[4, 6] =...
Question 35Which among the following options can be used to create a DataFrame in Pandas ?A scalar valueAn ndarrayA python dictAll of these
Question 36Identify the correct statement :The standard marker for missing data in Pandas is NaN.Series act in a way similar to that of an arrayBoth...
Question 37Identify the correct option to select first four rows and second to fourth columns from a DataFrame 'Data':display(Data.iloc[1 : 4, 2 :...
Question 38To delete a column from a DataFrame, you may use ............... statement.removedeldropcancel
Question 39To delete a row from a DataFrame, you may use ............... statement.removedeldropcancel
Question 40Sudhanshu has written the following code to create a DataFrame with boolean index :import numpy as np import pandas as pd df =...
Question 1A Pandas Series object can be thought of as a column or a row, essentially.
Question 2Both Series and DataFrame are one-dimensional data structure objects.
Question 3While series is a one-dimensional data structure object, dataframe is a multi-dimensional data structure object.
Question 4A Series object is value mutable.
Question 5A Series object is size mutable.
Question 6A DataFrame object is value mutable.
Question 7A DataFrame object is size mutable.
Question 8There is no difference between a NumPy array and a Series object.
Question 9A DataFrame can be thought of as a group of multiple Series objects.
Question 10A DataFrame has similar properties as a Series object.
Question 11A Series object can store only homogeneous (same type of) elements.
Question 12A DataFrame object can store only homogeneous elements.
Question 13The del statement can remove the rows as well as columns in a dataframe.
Question 14The rename() always makes changes in the default dataframe.
Question 1What is the significance of Pandas library ?
Question 2Name some common data structures of Python's Pandas library.
Question 3How is a Series object different from and similar to ndarrays ? Support your answer with examples.
Question 4Write single line Pandas statement for the following. (Assuming necessary modules have been imported) :Declare a Pandas series named...
Question 5Write commands to print following details of a Series object seal :(a) if the series is empty(b) indexes of the series(c) The data type of...
Question 6Given the following Series S1 and S2 :A10B40C34D60A80B20C74D90Write the command to find the sum of series S1 and S2.
Question 7Consider two objects x and y. x is a list whereas y is a Series. Both have values 20, 40, 90, 110.What will be the output of the following...
Question 8Given a dataframe df as shown below : ABD015171911618202202122What will be the result of following code statements ?(a) df['C'] = np.NaN(b)...
Question 9Write code statements to list the following, from a dataframe namely sales:(a) List only columns 'Item' and 'Revenue'.(b) List rows from 3...
Question 10Hitesh wants to display the last four rows of the dataframe df and has written the following code :df.tail() But last 5 rows are being...
Question 11How would you add a new column namely 'val' to a dataframe df that has 10 rows in it and has columns as 'Item', 'Qty', 'Price' ? You can...
Question 12Write code statements for a dataframe df for the following :(a) delete an existing column from it.(b) delete rows from 3 to 6 from it.(c)...
Question 13Write statement(s) to delete a row from a DataFrame.
Question 14Write statement(s) to delete a column from a DataFrame.
Question 15Write statement(s) to change the value at 5th row, 6th column in a DataFrame df.
Question 16Write statement(s) to change the values to 750 at 4th row to 9th row, 7th column in a DataFrame df.
Question 17What is the difference between iloc and loc with respect to a DataFrame ?
Question 18What is the difference between iat and at with respect to a DataFrame ?
Question 19How would you delete columns from a dataframe ?
Question 20How would you delete rows from a dataframe ?
Question 21Which function would you use to rename the index/column names in a dataframe ?
Question 1Consider following Series object namely S :0 0.430271 1 0.617328 2...
Question 2Consider the same Series object, S, given in the previous question. What output will be produced by following code fragment ?S.index =...
Question 3What will be the output produced by the following code ?Stationery = ['pencils', 'notebooks', 'scales', 'erasers'] S = pd.Series([20, 33,...
Question 4What will be the output produced by following code, considering the Series object S given above ?(a) print(S[1:1])(b) print(S[0:1])(c)...
Question 5Write a Python program to create a series object, country using a list that stores the capital of each country.Note. Assume four countries...
Question 6(a)Find the error in following code fragment :S2 = pd.Series([101, 102, 102, 104]) print(S2.index) S2.index = [0, 1, 2, 3, 4, 5]...
Question 6(b)Find the error in following code fragment :S = pd.Series(2, 3, 4, 5, index = range(4))
Question 6(c)Find the error in following code fragmentS1 = pd.Series(1, 2, 3, 4, index = range(7))
Question 6(d)Find the error in following code fragment :S2 = pd.Series([1, 2, 3, 4], index = range(4))
Question 7Find the Error :data = np.array(['a', 'b', 'c', 'd', 'e', 'f']) s = pd.Series(data, index = [100, 101, 102, 103, 104, 105])...
Question 8Why does following code cause error ?s1 = pd.Series(range(1, 15, 3), index = list('abcd'))
Question 9Why does following code cause error ?s1 = pd.Series(range(1, 15, 3), index = list('ababa')) print(s1['ab'])
Question 10If Ser is a Series type object having 30 values, then how are statements (a), (b) and (c), (d) similar and different ?(a)...
Question 11What advantages does dataframe offer over series data structure ? If you have similar data stored in multiple series and a single...
Question 12Create a DataFrame in Python from the given list :[['Divya', 'HR', 95000], ['Mamta', 'Marketing', 97000], ['Payal', 'IT', 980000],...
Question 13Carefully observe the following code :import pandas as pd Year1 = {'Q1': 5000, 'Q2': 8000, 'Q3': 12000, 'Q4': 18000} Year2 = {'A': 13000,...
Question 14Given :import pandas as pd d = {'one' : pd.Series([1., 2., 3.], index = ['a', 'b', 'c']), 'two' : pd.Series([1., 2., 3., 4.], index =...
Question 15(a)From the DataFrames created in previous question, write code to display only row 'a' from DataFrames df, df1, and df2.Solutionimport...
Question 15(b)From the DataFrames created in previous question, write code to display only rows 0 and 1 from DataFrames df, df1, and...
Question 15(c)From the DataFrames created in previous question, write code to display only rows 'a' and 'b' for columns 1 and 2 from DataFrames df,...
Question 15(d)From the DataFrames created in previous question, write code to add an empty column 'x' to all DataFrames.Solutionimport pandas as pd d...
Question 16What will be the output of the following program ?import pandas as pd dic = {'Name' : ['Sapna', 'Anmol', 'Rishul', 'Sameep'], 'Agg' : [56,...
Question 17Predict the output of following code (it uses below given dictionary my_di).my_di = {"name" : ["Jiya", "Tim", "Rohan"], "age" :...
Question 18Consider the same dictionary my_di in the previous question (shown below), what will be the output produced by following code ?my_di =...
Question 19Assume that required libraries (panda and numpy) are imported and dataframe df2 has been created as per questions 17 and 18 above. Predict...
Question 20Assume that required libraries (panda and numpy) are imported and dataframe df2 has been created as per questions 17 and 18 above. Predict...
Question 21Assume that required libraries (panda and numpy) are imported and dataframe df2 has been created as per questions 17 and 18 above. Predict...
Question 22Assume that required libraries (panda and numpy) are imported and dataframe df2 has been created as per questions 17 and 18 above. Predict...
Question 23What is the output of the following code ?d = {'col1': [1, 4, 3 ], 'col2': [6, 7, 8], 'col3': [9, 0, 1]} df = pd.DataFrame(d)...
Question 24What is the output of the following code ?data = {'age': [20, 23, 22], 'name': ['Ruhi', 'Ali', 'Sam']} df1 = pd.DataFrame(data, index=[1,...
Question 25Consider the given DataFrame 'Genre' :NoTypeCode0FictionF1Non-fictionNF2DramaD3PoetryPWrite suitable Python statements for the following...
Question 26Write a program in Python Pandas to create the following DataFrame batsman from a Dictionary :B_NONameScore1Score21Sunil Pillai90802Gaurav...
Question 27Consider the following dataframe, and answer the questions given below:import pandas as pd df = pd.DataFrame( { "Quarter1": [2000, 4000,...
Question 28Write the use of the rename(mapper = <dict-like>, axis = 1) method for a Pandas Dataframe. Can the mapper and columns parameter be...
Question 29Find the error in the following code ? Suggest the solution.>>> topDf RollNo Name Marks Sec A 115 Pavni...
Question 30Find the error in the following code considering the same dataframe topDf given in the previous question.(i) topDf.rename(index=['a', 'b',...
Question 1Write Python code to create a Series object Temp1 that stores temperatures of seven days in it. Take any random seven...
Question 2Write Python code to create a Series object Temp2 storing temperatures of seven days of week. Its indexes should be 'Sunday', 'Monday',......
Question 3A series object (say T1) stores the average temperature recorded on each day of a month. Write code to display the temperatures recorded on...
Question 4Series objects Temp1, Temp2, Temp3, Temp4 store the temperatures of days of week1, week2, week3, week4 respectively.Write a script to(a)...
Question 5Ekam, a Data Analyst with a multinational brand has designed the DataFrame df that contains the four quarters' sales data of different...
Question 6(i)Consider the following DataFrame df and answer any four questions from (i)-(v):rollnonameUT1UT2UT3UT41Prerna Singh242420222Manish...
Question 6(ii)Consider the following DataFrame df and answer any four questions from (i)-(v):rollnonameUT1UT2UT3UT41Prerna Singh242420222Manish...
Question 6(iii)Consider the following DataFrame df and answer any four questions from (i)-(v):rollnonameUT1UT2UT3UT41Prerna Singh242420222Manish...
Question 6(iv)Consider the following DataFrame df and answer any four questions from (i)-(v):rollnonameUT1UT2UT3UT41Prerna Singh242420222Manish...
Question 6(v)Consider the following DataFrame df and answer any four questions from (i)-(v):rollnonameUT1UT2UT3UT41Prerna Singh242420222Manish...
Question 7Write a program that stores the sales of 5 fast moving items of a store for each month in 12 Series objects, i.e., S1 Series object stores...
Question 8Three Series objects store the marks of 10 students in three terms. Roll numbers of students form the index of these Series objects. The...
Question 9Write code to print all the information about a Series object.Solutionimport pandas as pd s = pd.Series([1, 2, 3, 4], index=['a', 'b', 'c',...
Question 10Write a program to create three different Series objects from the three columns of a DataFrame df.Solutionimport pandas as pd df =...
Question 11Write a program to create three different Series objects from the three rows of a DataFrame df.Solutionimport pandas as pd df =...
Question 12Write a program to create a Series object from an ndarray that stores characters from 'a' to 'g'.Solutionimport pandas as pd import numpy...
Question 13Write a program to create a Series object that stores the table of number 5.Solutionimport pandas as pd import numpy as np arr =...
Question 14Write a program to create a Dataframe that stores two columns, which store the Series objects of the previous two questions (12 and...
Question 15Write a program to create a Dataframe storing salesmen details (name, zone, sales) of five salesmen.Solutionimport pandas as pd salesmen =...
Question 16Four dictionaries store the details of four employees-of-the-month as (empno, name). Write a program to create a dataframe from...
Question 17A list stores three dictionaries each storing details, (old price, new price, change). Write a program to create a dataframe from...