40 NumPy and Pandas Interview Questions With Answers 1740141557
40 NumPy and Pandas Interview Questions With Answers 1740141557
m
da
Ka
v)
na
ra
(P
m
You can install NumPy using:
da
pip install numpy
Ka
3. How do you create a NumPy array?
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
v)
print(arr) na
4. What are the advantages of NumPy over Python lists?
ra
● Faster operations due to optimized C implementation
● Uses less memory
(P
m
9. How do you find the mean, median, and standard deviation in
NumPy?
da
np.mean(arr)
np.median(arr)
Ka
np.std(arr)
10. How do you find the maximum and minimum values in a NumPy
v)
array?
arr.max() # Maximum value
na
arr.min() # Minimum value
ra
Example:
a = np.array([1, 2, 3])
b = np.array([[1], [2], [3]])
result = a + b # Broadcasting happens here
14. How do you generate random numbers in NumPy?
np.random.rand(3, 3) # Random numbers between 0 and 1
np.random.randint(1, 100, (3, 3)) # Random integers
m
Pandas Interview Questions
da
16. What is Pandas?
Ka
Pandas is a Python library used for data analysis and manipulation. It provides data
structures like Series and DataFrame for handling tabular data.
v)
17. How do you install Pandas?
pip install pandas
na
18. What are the two main data structures in Pandas?
ra
import pandas as pd
s = pd.Series([1, 2, 3, 4])
ke
print(s)
hi
m
25. How do you remove duplicate rows in Pandas?
df.drop_duplicates()
da
26. How do you rename columns in Pandas?
Ka
df.rename(columns={'OldName': 'NewName'}, inplace=True)
v)
27. How do you filter data in Pandas?
df[df['Age'] > 25]
na
28. How do you sort a DataFrame in Pandas?
ra
df.sort_values(by='Age', ascending=False)
(P
df.groupby('Category').sum()
ke
m
df['Date'] = pd.to_datetime(df['Date'])
da
36. How do you pivot a DataFrame?
Ka
df.pivot(index='Date', columns='Category', values='Sales')
v)
● Series: One-dimensional
na
● DataFrame: Two-dimensional
df.describe()
(P
df.to_csv('output.csv', index=False)
ke
These 40 NumPy and Pandas interview questions will help you prepare for your
next Data Science or Data Analytics job interview.
R