WorksheetsPandas
Total questions: 17
Worksheet time: 17mins
What method is used to read a CSV file using pandas?
Which of the following will return the number of non-null entries in each column?
df.size
df.shape
df.count()
df.columns
What is the output of df.shape?
List of (columns, rows)
List of (rows, columns)
Tuple of (rows, columns)
Tuple of (columns, rows)
How can you check for missing values in a DataFrame?
df.empty()
df.find_nulls()
df.missing()
df.isnull()
Which function is used to drop rows with missing values?
df.remove_na()
df.delete()
df.dropna()
df.clean_null()
How to fill missing values with zero?
df.nulls(0)
df.insertna(0)
df.fillna(0)
df.replace_null(0)
Which method is used to reset the index of a DataFrame?
df.reindex()
df.reset_index()
df.set_index(None)
df.index_reset()
What should be the axis value for df.drop() when dropping a column?
0
1
-1
2
What does df[df['Age'] > 25] do?
Filter all rows where Age is less than 25
Return Age column where Age is greater then 25
Filter rows where Age is greater than 25
Returns all rows
What does df.groupby('Department') do?
Sorts the DataFrame
Groups the DataFrame by 'Department' column
Filters the DataFrame
Filter the Department column
What is the default merge type in pd.merge()?
outer
inner
left
right
How to rename column names in pandas?
df.changename(columns={'old':'new'})
df.rename(columns={'old':'new'})
df.retitle()
df.setname()
How can we sort a DataFrame by a column named 'Salary'?
df.sort_values('Salary')
df.sort('Salary')
df.order_by('Salary')
df.sorted('Salary')
What is the difference between iloc[] and loc[]?
iloc[] uses index positions, loc[] uses labels
iloc[] uses labels, loc[] uses positions
loc[] is faster than iloc[]
Both are the same
What does df.duplicated(subset=['A'], keep=False) do?
Returns True for all duplicated values in all columns
Returns True for all duplicate rows in column 'A'
Returns True for only first occurrence
Removes duplicate values
What does the drop_duplicates(keep=False) do?
Keeps all duplicates
Drops all instances of duplicates
Keeps first duplicate only
Keeps last duplicate only
Which operation is faster for large datasets: df.loc[] or df.iloc[]?
loc
iloc
Both are same
Depends on dtype
