Top 100 Python Interview Questions for Data Analyst
Top 100 Python Interview Questions for Data Analyst
🔹 Python Fundamentals
1. What are Python's key features?
Python is interpreted, dynamically typed, high-level, portable, open-source, object-oriented, and
has rich standard libraries.
5. What is PEP8?
PEP8 is Python’s official style guide for writing readable code.
python
CopyEdit
Q1 = df.quantile(0.25)
Q3 = df.quantile(0.75)
IQR = Q3 - Q1
df = df[~((df < (Q1 - 1.5 * IQR)) | (df > (Q3 + 1.5 *
IQR))).any(axis=1)]
python
CopyEdit
def factorial(n): return 1 if n == 0 else n * factorial(n - 1)
59. Count missing values per column?
df.isnull().sum()
python
CopyEdit
from collections import Counter
Counter(text.split())
def is_palindrome(s):
return s == s[::-1]
def most_frequent(lst):
return Counter(lst).most_common(1)[0][0]
83. Given a list of numbers, return a list with only the even numbers.
def filter_even(lst):
def reverse_words(sentence):
86. Write a Python program to find the second highest number in a list.
def second_highest(lst):
return sorted(set(lst))[-2]
import string
def remove_punctuation(text):
def count_vowels(s):
def flatten(lst):
90. How would you group a DataFrame by a column and get the mean of each group?
df.groupby('column').mean()
def primes_less_than(n):
def is_leap(year):
import pandas as pd
df = pd.DataFrame([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}])
def longest_word(sentence):
98. How to read only specific columns from a CSV using pandas?
df.corr()
def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b