1. What is Pandas and why is it used?
Pandas is a data manipulation and analysis library built on top of NumPy. It provides two main structures: Series (1D) and DataFrame (2D), making it easy to clean, analyze, and visualize data.
2. How do you create a DataFrame?
import pandas as pd
data = {'Name': ['Alice', 'Bob'], 'Age': [25, 30]}
df = pd.DataFrame(data)
3. Difference between Series and DataFrame
⦁ Series: 1D labeled array (like a single column), homogeneous data types, immutable size.
⦁ DataFrame: 2D table with rows & columns (like a spreadsheet), heterogeneous data types, mutable size.
4. How to read/write CSV files?
df = pd.read_csv('data.csv')
df.to_csv('output.csv', index=False)5. How to handle missing data in Pandas?
⦁
df.isnull() — identify nulls⦁
df.dropna() — remove missing rows⦁
df.fillna(value) — fill with default6. How to filter rows in a DataFrame?
df[df['Age'] > 25]7. What is groupby() in Pandas?
Used to split data into groups, apply a function, and combine the result.
Example:
df.groupby('Department')['Salary'].mean()8. Difference between loc[] and iloc[]?
⦁
loc[]: label-based indexing⦁
iloc[]: index-based (integer)9. How to merge/join DataFrames?
Use
pd.merge() to combine DataFrames on a key pd.merge(df1, df2, on='ID', how='inner')10. How to sort data in Pandas?
df.sort_values(by='Age', ascending=False)💡 Pandas is key for data cleaning, transformation, and exploratory data analysis (EDA). Master it before jumping into ML!
Double Tap ❤️ For More!