Pandas Interview Questions and Answers
Ques 6. How to drop a column in a DataFrame?
You can drop a column using the drop() method: df.drop('ColumnName', axis=1, inplace=True)
Is it helpful?
Add Comment
View Comments
Ques 7. Explain the use of groupby() in Pandas.
groupby() is used to group DataFrame by a column and perform aggregate functions.
Example:
df.groupby('Column').mean()
Is it helpful?
Add Comment
View Comments
Ques 8. What is the purpose of the apply() function in Pandas?
apply() is used to apply a function along the axis of a DataFrame.
Example:
df['Column'].apply(lambda x: x*2)
Is it helpful?
Add Comment
View Comments
Ques 9. Explain the use of merge() in Pandas.
merge() is used to combine two DataFrames based on a common column.
Example:
pd.merge(df1, df2, on='common_column')
Is it helpful?
Add Comment
View Comments
Ques 10. How to handle missing values in a DataFrame?
You can use methods like dropna() to remove missing values or fillna() to fill them with a specific value.
Example:
df.dropna() or df.fillna(value)
Is it helpful?
Add Comment
View Comments
Most helpful rated by users: