Suggestion: If you didn't find the question, Search by options to get a more accurate result.
Quiz on Pandas Data Structures
1.What is the information sort of collection s described in beneath code?
import pandas as pd
s = pd.Series([9.2, 'hello', 89])
item
str
float
int
Answer: 1)item
2.What is the form of the information body df described withinside the beneath-proven code?
import pandas as pd
information = [, ]
df = pd.DataFrame(information, columns=['a', 'b'])
(3,)
(2,2)
Data Frame df isn't created
(2,3)
Answer: 2)(2,2)
3.What is the output of the expression 'b' in s, wherein s is the collection described as proven beneath?
s = pd.Series([89.2, 76.4, 98.2, 75.9], index=listing('abcd'))
Error
True
False
None of the options
Answer: 2)True
4.Which of the subsequent argument is used to label the factors of a chain?
labels
values
factors
index
Answer: 4)index
5.Which of the subsequent expressions are used to test if every detail of a chain s is gift withinside the listing of factors [67, 32]. Series s is described as proven beneath.
s = pd.Series([99, 32, 67],listing('abc'))
[67, 32] isin s
s in [67, 32]
[67, 32] in s
s.isin([67, 32])
Answer: 4)s.isin([67, 32])
6.Which of the subsequent can not be used to create a Data body?
A dictionary of tuples
A tuple of tuples
A dictionary of lists
A listing of lists
Answer: 2)A tuple of tuples
7.Which of the subsequent isn't a Data Structure of Pandas?
Data Frame
Series
Dictionary
Panel
Answer: 3)Dictionary
8.What is the output of the subsequent code?
import pandas as pd
s = pd.Series([89.2, 76.4, 98.2, 75.9], index=listing('abcd'))
print(s[['c', 'a']])
a 89.2
c 98.2
dtype: float64
c 98.2
a 89.2
dtype: float64
c 98.2, a 89.2
a 89.2, c 98.2
Answer: 2)c 98.2
a 89.2
dtype: float64
9.What is the form of the information body df described withinside the beneath-proven code?
import pandas as pd
information = [, ]
df = pd.DataFrame(information)
(2,3)
Data Frame df isn't created
(2,2)
(3,)
Answer: 1)(2,3)
10.Which of the subsequent attributes or arguments are used to set column names of a information body?
columns
column
index
indexes
Answer: 1)columns
Quiz on Accessing Data Elements
1.Which of the subsequent expression returns ultimate rows of df, described beneath?
import pandas as pd
df = pd.DataFrame(, index=['r1', 'r2', 'r3'])
df.iloc[:'r3']
df.loc['r2':'r3']
df.iloc['r2':'r3']
df.loc[:'r3']
Answer: 2)df.loc['r2':'r3']
2.Which of the subsequent expression returns the primary rows of df, described beneath?
import pandas as pd
df = pd.DataFrame(, index=['r1', 'r2', 'r3'])
df.iloc[:2]
Both df[:2] and df.iloc[:2]
df[:2]
None of the options
Answer: 2)Both df[:2] and df.iloc[:2]
3.What does the expression df.loc['r4'] = [67, 78] do for the information body df, described beneath?
df = pd.DataFrame(, index=['r1', 'r2', 'r3'])
Over writes the ultimate row
Adds a brand new row
Adds a column
Results in Error
Answer: 2)Adds a brand new row
4.Which of the subsequent expression is used to feature a brand new column 'C' to a information body df, with 3 rows?
df.ix['C'] = [12, 98, 45]
df.loc['C'] = [12, 98, 45]
df['C'] = [12, 98, 45]
df.iloc['C'] = [12, 98, 45]
Answer: 3)df['C'] = [12, 98, 45]
5.Which of the subsequent expression returns the second one row of df, described beneath?
import pandas
df = pd.DataFrame(, index=['r1', 'r2', 'r3'])
df.loc[1]
df[1]
df.iloc['r2']
df.iloc[1]
Answer: 4)df.iloc[1]
6.Which of the subsequent expression is used to delete the column, A from a information body named df?
get rid of df['A']
rm df['A']
del df['A']
delete df['A']
Answer: 3)del df['A']
7.Which of the subsequent expression returns information of column B of information body df, described beneath?
import pandas as pd
df = pd.DataFrame(, index=['r1', 'r2', 'r3'])
None of the options
df.B
df['A']
df[1]
Answer: 2)df.B
Quiz on I/O in pandas
1.State whether or not the subsequent announcement is authentic or false? The read_csv approach can examine a couple of columns of an enter report as indexes.
False
True
Answer: 2)True
2.Which of the subsequent approach is used to examine information from excel files?
read_excel
excel_read
excel_reader
examine
Answer: 1)read_excel
3.Which of the subsequent is used as argument of read_csv approach to deal with information of unique columns as dates?
date_parse
date_col
parse_dates
dates
Answer: 3)parse_dates
4.State whether or not the subsequent announcement is authentic or false? The read_csv approach, with the aid of using default, reads all clean strains of an enter CSV report.
False
True
Answer: 1)False
5.Which of the subsequent is used as an issue of read_csv approach to bypass first n strains of an enter CSV report?
bypass
skipn
skipnrows
skiprows
Answer: 4)skiprows
6.________ is used as an issue of the readcsv approach to make information of a selected column as an index.
index
id
id_col
index_col
Answer: 4)index_col
7.Which of the subsequent approach is used to jot down a information body information to an output CSV report?
csv_write
write_csv
to_csv
csv_writer
Answer: 3)to_csv
Quiz on Indexing
1.What is the period of DatetimeIndex item created with the beneath expression?
pd.date_range('11-Sep-2017', '17-Sep-2017', freq='2D')
4
6
3
7
Answer: 1)4
2.What is the output of the subsequent code?
import pandas as pd
d = pd.date_range('11-Sep-2017', '17-Sep-2017', freq='2D')
len(d[d.isin(pd.to_datetime(['12-09-2017', '15-09-2017']))])
2
4
1
0
Answer: 3)1
3.What does the expression d + pd.Timedelta('1 days 2 hours') do to DatetimeIndex item d, described beneath?
d = pd.date_range('11-Sep-2017', '17-Sep-2017', freq='2D')
Increases every datetime cost with the aid of using 1 day and a couple of hours
Results in Error
Increases every datetime cost with the aid of using 1 day
No adjustments to every datetime cost
Answer: 1)Increases every datetime cost with the aid of using 1 day and a couple of hours
4.Which of the subsequent approach is used to transform a listing of dates like strings into datetime objects?
datetime
date
to_datetime
to_date
Answer: 3)to_datetime
5.What is the period of PeriodIndex item constituted of the expression pd.period_range('11-Sep-2017', '17-Sep-2017', freq='M')?
1
0
6
3
Answer: 1)1
6.What is the period of DatetimeIndex item created with the beneath expression?
pd.bdate_range('11-Sep-2017', '17-Sep-2017', freq='2D')
4
7
3
6
Answer: 1)4
Quiz on Data Cleaning
1.By default, lacking values in any information set are examine as ...........
NA
NaN
.
0
Answer: 2)NaN
2.Which of the subsequent approach is used to fill null values with a deafult cost?
fill
keepna
fillna
keep
Answer: 3)fillna
3.Which of the subsequent approach of pandas is used to test if every cost is a null or not?
NULL
isnan
isnull
ifnull
Answer: 3)isnull
4.Which of the subsequent strategies is used to get rid of duplicates?
remove_dup
get rid of
drop_dup
drop_duplicates
Answer: 4)drop_duplicates
5.Which of the subsequent argument values are allowed for the approach argument of fillna?
pad
bfill
All
backfill
ffill
Answer: 3)All
6.Which of the subsequent approach is used to dispose of rows with null values?
dropna
drop
get rid of
removena
Answer: 1)dropna
7.Unrecognized datetime cost is handled as _________.
NaV
NaD
NaT
NaN
Answer: 3)NaT
Quiz on Data Aggregation
1.Which of the subsequent strategies is used to organization information of a information body, primarily based totally on unique columns?
groupby
combination
organization
groupat
Answer: 1)groupby
2.What does the expression df.iloc[:, lambda x : [0,3]] do? Consider a information body df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2', 'r3'].
Selects Column 'A' and 'C'
Results in Error
Selects Columns 'A', 'B', and 'C'
Selects Column 'A' and 'D'
Answer: 4)Selects Column 'A' and 'D'
3.Consider a information body df with 10 rows and index [ 'r1', 'r2', 'r3', 'row4', 'row5', 'row6', 'r7', 'r8', 'r9', 'row10']. What does the expression g = df.groupby(df.index.str.len()) do?
Groups df primarily based totally on index values
Groups df primarily based totally on period of every index cost
Groups df primarily based totally on index strings
Data frames can not be grouped with the aid of using index values. Hence it consequences in Error.
Answer: 4)Data frames can not be grouped with the aid of using index values. Hence it consequences in Error.
4.Consider a information body df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2', 'r3'], Which of the subsequent expression is used to extract columns 'C' and 'D'?
df.loc[:, lambda x : x.columns.isin(['C', 'D'])]
df[:, lambda x : x.columns.isin(['C', 'D'])]
lambda x : x.columns.isin(['C', 'D'])
None
Answer: 1)df.loc[:, lambda x : x.columns.isin(['C', 'D'])]
5.Which of the subsequent approach may be carried out on a groupby item to get the organization details?
group_details
groups
get_groups
fetch_groups
Answer: 2)groups
6.Consider a information body df with 10 rows and index [ 'r1', 'r2', 'r3', 'row4', 'row5', 'row6', 'r7', 'r8', 'r9', 'row10']. How many rows are acquired after executing the beneath expressions
g = df.groupby(df.index.str.len())
g.filter(lambda x: len(x) > 1)
9
1
5
10
Answer: 1)9
7.Consider a information body 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?
Returns the row call r3
Results in Error
Returns the 1/3 column
Filters the row labelled r3
Answer: 4)Filters the row labelled r3
8.Consider a information body df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2', 'r3']. Which of the subsequent expression filters the rows whose column B values are extra than forty five and column 'C' values are much less than 30?
df.loc[(df.B > forty five) & (df.C < 30> forty five & df.C < 30> forty five & df.C < 30> forty five) & (df.C < 30> forty five) & (df.C < 30> forty five]
df.B > forty five
df[df.B > 45]
df.loc[B > 45]
Answer: 3)df[df.B > 45]
10.Consider a information body df with 10 rows and index [ 'r1', 'r2', 'r3', 'row4', 'row5', 'row6', 'r7', 'r8', 'r9', 'row10']. What does the combination approach proven in beneath code do?
g = df.groupby(df.index.str.len())
g.combination()
Computes Sum of column A values
Computes period of column A
Computes period of column A and Sum of Column B values of every organization
Computes period of column A and Sum of Column B values
Answer: 3)Computes period of column A and Sum of Column B values of every organization
Quiz on Data Merging
1.Which of the subsequent argument is used to disregard the index at the same time as concatenating information frames?
index
no_index
ignore_index
ignore
Answer: 3)ignore_index
2.Which of the subsequent approach is used to concatenate or extra information frames?
con
concatenate
concat
.
Answer: 3)concat
3.What is the form of d described in beneath code?
import pandas as pd
s1 = pd.Series([0, 1, 2, 3])
s2 = pd.Series([0, 1, 2, 3])
s3 = pd.Series([0, 1, 4, 5])
d = pd.concat([s1, s2, s3], axis=1)
(4,4)
(4,3)
(3,4)
(3,3)
Answer: 2)(4,3)
4.Which of the subsequent argument is used to set the important thing for use for merging information frames?
key
on
k
keyon
Answer: 2)on
5.Which argument is used to override the prevailing column names, at the same time as the usage of concat approach?
columns
override
new
keys
Answer: 4)keys
6.Which of the subsequent are allowed values of the argument how of merge approach?
inner
right
All the options
outer
left
Answer: 3)All the options
0 Comments