🔹 Load and Setup

import pandas as pd

# Load Excel File
df = pd.read_excel("indian_customer_data.xlsx")

# Convert registration date to datetime
df['Date of Registration'] = pd.to_datetime(df['Date of Registration'], errors='coerce')

🔹 Part A: Basic Filtering

# Customers aged 30 and above
age_30_above = df[df['Age'] >= 30]

# Customers from Tamil Nadu
from_tamil_nadu = df[df['State'].str.lower() == 'tamil nadu']

# Female customers in Delhi
female_in_delhi = df[(df['Gender'].str.lower() == 'female') & (df['State'].str.lower() == 'delhi')]

# Customers registered after 1st Jan 2023
registered_after_2023 = df[df['Date of Registration'] > '2023-01-01']

🔹 Part B: String Conditions

# Names starting with 'D'
starts_with_d = df[df['Full Name'].str.startswith('D')]

# Emails ending with @yahoo.com
email_yahoo = df[df['Email'].str.endswith('@yahoo.com')]

# Address containing 'Nagar'
address_contains_nagar = df[df['Address'].str.contains('Nagar', case=False, na=False)]

# Aadhaar middle four digits = 5405
aadhaar_middle_5405 = df[df['Aadhaar'].str[5:9] == '5405']

🔹 Part C: Cleanup and Derivation

# Add Initial and Registration Year
df['Initial'] = df['Full Name'].str[0]
df['Registration Year'] = df['Date of Registration'].dt.year

# Customers who registered in 2024
registered_2024 = df[df['Registration Year'] == 2024]

📌 Explanation