HomeInterview QuestionsHow do you perform basic operations on a dataframe…

How do you perform basic operations on a dataframe?

🟢 Easy Conceptual Fresher level
1Times asked
Sep 2026Last seen
Sep 2026First seen

💡 Model Answer

Basic dataframe operations are the foundation of data manipulation in libraries like Pandas or Spark. 1. Selection – df['col'] or df[['col1', 'col2']] returns a column or subset. 2. Filtering – df[df['col'] > 10] keeps rows that satisfy a condition. 3. Aggregation – df.groupby('col').sum() or df.agg({'col': 'mean'}) computes statistics per group. 4. Joining – df.merge(other, on='id', how='inner') combines two dataframes on a key. 5. Sorting – df.sort_values('col', ascending=False) orders rows. 6. Pivoting – df.pivot_table(index='id', columns='type', values='value') reshapes data. 7. Adding columns – df['new'] = df['a'] + df['b'] creates derived columns. 8. Handling missing data – df.dropna() or df.fillna(0) cleans nulls. These operations can be chained or applied in a pipeline, and they work similarly in Spark DataFrames with slight API differences.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500