Pandas
Pandas
import pandas as pd
import pandas as pd
What is the output of the expression 'b' in s, where s is the series defined as
shown below?
m
er as
Which of the following argument is used to label the elements of a series? -
co
index
eH w
o.
What is the data type of series s defined in below code?
rs e
ou urc
import pandas as pd
Which of the following expressions are used to check if each element of a series
aC s
below.
tuples
ar stu
Which of the following attributes or arguments are used to set column names of a
data frame? - columns
What is the shape of the data frame df defined in the below-shown code?
sh is
import pandas as pd
Th
---------------------------------------------
Which of the following expression returns the first two rows of df, defined
below?
import pandas as pd
What does the expression df.loc['r4'] = [67, 78] do for the data frame df,
defined below?
This study source was downloaded by 100000832806195 from CourseHero.com on 10-04-2021 05:24:48 GMT -05:00
https://www.coursehero.com/file/76923338/Pandastxt/
df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2',
'r3']) - Adds a new row
Which of the following expression returns data of column B of data frame df,
defined below?
import pandas as pd
Which of the following expression returns the second row of df, defined below?
import pandas
Which of the following expression is used to add a new column 'C' to a data
frame df, with three rows? - df['C'] = [12, 98, 45]
m
er as
Which of the following expression returns last two rows of df, defined below?
co
eH w
import pandas as pd
o.
df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2',
rs e
'r3']) - df.loc['r2':'r3']
ou urc
Which of the following expression is used to delete the column, A from a data
frame named df? - del df['A']
o
-----------------------------------------------
aC s
v i y re
Which of the following method is used to write a data frame data to an output
CSV file? - to_csv
ed d
ar stu
Which of the following method is used to read data from excel files? -
read_excel
State whether the following statement is true or false? The read_csv method can
read multiple columns of an input file as indexes. - True
sh is
State whether the following statement is true or false? The read_csv method, by
Th
Which of the following method is used to read data from excel files? -
read_excel
------------------------------------------------
This study source was downloaded by 100000832806195 from CourseHero.com on 10-04-2021 05:24:48 GMT -05:00
https://www.coursehero.com/file/76923338/Pandastxt/
What is the length of DatetimeIndex object created with the below expression?
import pandas as pd
What is the length of DatetimeIndex object created with the below expression?
Which of the following method is used to convert a list of dates like strings
m
into datetime objects? - to_datetime
er as
co
-----------------------------------------------------
eH w
Which of the following argument values are allowed for the method argument of
o.
fillna? - All rs e
ou urc
Which of the following method of pandas is used to check if each value is a null
or not?- isnull
Which of the following method is used to fill null values with a deafult value?
o
- fillna
aC s
v i y re
Which of the following method is used to eliminate rows with null values? - 4
-----------------------------------------------------------
ed d
ar stu
Which of the following methods is used to group data of a data frame, based on
specific columns? - groupby
Consider a data frame df with 10 rows and index [ 'r1', 'r2', 'r3', 'row4',
'row5', 'row6', 'r7', 'r8', 'r9', 'row10']. How many rows are obtained after
sh is
g = df.groupby(df.index.str.len())
g.filter(lambda x: len(x) > 1) - 9
Which of the following method can be applied on a groupby object to get the
group details? - groups
Consider a data frame df with 10 rows and index [ 'r1', 'r2', 'r3', 'row4',
'row5', 'row6', 'r7', 'r8', 'r9', 'row10']. What does the aggregate method shown
in below code do?
g = df.groupby(df.index.str.len())
g.aggregate({'A':len, 'B':np.sum}) - Computes length of column A and Sum of
Column B values of each group
(w)Consider a data frame df with 10 rows and index [ 'r1', 'r2', 'r3', 'row4',
'row5', 'row6', 'r7', 'r8', 'r9', 'row10']. What does the expression g =
This study source was downloaded by 100000832806195 from CourseHero.com on 10-04-2021 05:24:48 GMT -05:00
https://www.coursehero.com/file/76923338/Pandastxt/
df.groupby(df.index.str.len()) do? - Groups df based on index values
Consider a data frame df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2',
'r3'], Which of the following expression is used to extract columns 'C' and 'D'?
- df.loc[:, lambda x : x.columns.isin(['C', 'D'])]
Consider a data frame df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2',
'r3']. What does the expression df[lambda x : x.index.str.endswith('3')] do? -
Filters the row labelled r3
Consider a data frame df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2',
'r3']. Which of the following expression filters the rows whose column B values
are greater than 45 and column 'C' values are less than 30? - df.loc[(df.B > 45)
& (df.C < 30)]
What does the expression df.iloc[:, lambda x : [0,3]] do? Consider a data frame
df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2', 'r3']. - Selects
Column 'A' and 'D'
Consider a data frame df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2',
'r3']. Which of the following expression filters the rows whose column B values
are greater than 45? - df[df.B > 45]
m
er as
----------------------------------------------------
co
Which of the following argument is used to ignore the index while concatenating
eH w
two data frames? - ignore_index
o.
Which argument is used to override the existing column names, while using concat
rs e
method? - keys
ou urc
What is the shape of d defined in below code?
import pandas as pd
o
aC s
s1 = pd.Series([0, 1, 2, 3])
v i y re
s2 = pd.Series([0, 1, 2, 3])
s3 = pd.Series([0, 1, 4, 5])
d = pd.concat([s1, s2, s3], axis=1) - (4,3)
Which of the following are allowed values of the argument how of merge method? -
ed d
Which of the following method is used to concatenate two or more data frames? -
concat
sh is
Th
This study source was downloaded by 100000832806195 from CourseHero.com on 10-04-2021 05:24:48 GMT -05:00
https://www.coursehero.com/file/76923338/Pandastxt/
Powered by TCPDF (www.tcpdf.org)