Pandas Questions et reponses d'entretien
Question 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)
Question 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()
Question 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)
Question 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')
Question 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)
Les plus utiles selon les utilisateurs :