- Which library provides support for arrays in Python Data Science?
View Answer
Correct answer: A — NumPy
- What will be printed?
1 python 2 import numpy as np 3 a = np.array([1,2,3]) 4 print(a.shape) View Answer
Correct answer: A — (3,)
- Which function creates an array of zeros in NumPy?
View Answer
Correct answer: A — np.zeros()
- What is the output of print(np.zeros((2,2)))?
View Answer
Correct answer: A — [[0. 0.] [0. 0.]]
- Which function creates an identity matrix?
View Answer
Correct answer: A — np.eye()
- What will be printed?
1 python 2 import numpy as np 3 print(np.eye(3)) View Answer
Correct answer: A — 3x3 identity matrix
- Which function creates evenly spaced values?
View Answer
Correct answer: A — np.linspace()
- What is the output of print(np.linspace(1,5,5))?
View Answer
Correct answer: A — [1. 2. 3. 4. 5.]
- Which function reshapes an array?
View Answer
Correct answer: A — reshape()
- What will be printed?
1 python 2 import numpy as np 3 a = np.array([1,2,3,4]) 4 print(a.reshape(2,2)) View Answer
Correct answer: A — [[1 2] [3 4]]
- Which function performs matrix multiplication?
View Answer
Correct answer: D — Both A and C
- What is the output of below code?
1 python 2 import numpy as np 3 a = np.array([[1,2],[3,4]]) 4 b = np.array([[5,6],[7,8]]) 5 print(np.dot(a,b)) View Answer
Correct answer: A — [[19 22] [43 50]]
- Which function computes mean in NumPy?
View Answer
Correct answer: A — np.mean()
- What will be printed?
1 python 2 import numpy as np 3 print(np.mean([1,2,3])) View Answer
Correct answer: A — 2.0
- Which library provides Series and DataFrame?
View Answer
Correct answer: A — Pandas
- What is the output of below code?
1 python 2 import pandas as pd 3 s = pd.Series([1,2,3]) 4 print(type(s)) View Answer
Correct answer: A — <class 'pandas.core.series.Series'>
- Which function creates a DataFrame?
View Answer
Correct answer: A — pd.DataFrame()
- What will be printed?
1 python 2 import pandas as pd 3 df = pd.DataFrame({"Eduinq":[1,2,3]}) 4 print(df.shape) View Answer
Correct answer: A — (3,1)
- Which function reads CSV file in Pandas?
View Answer
Correct answer: A — pd.read_csv()
- What is the output of below code?
1 python 2 import pandas as pd 3 print(hasattr(pd,"read_csv")) View Answer
Correct answer: A — True
- Which function shows first rows of DataFrame?
View Answer
Correct answer: A — head()
- What will be printed?
1 python 2 import pandas as pd 3 df = pd.DataFrame({"Eduinq":[1,2,3]}) 4 print(df.head(2)) View Answer
Correct answer: A — First 2 rows
- Which function shows last rows of DataFrame?
View Answer
Correct answer: A — tail()
- What is the output of df.tail(1)?
View Answer
Correct answer: A — Last row
- Which function describes statistics of DataFrame?
View Answer
Correct answer: A — describe()
- What will be printed?
1 python 2 import pandas as pd 3 df = pd.DataFrame({"Eduinq":[1,2,3]}) 4 print("mean" in df.describe().index) View Answer
Correct answer: A — False
- Which function shows DataFrame info?
View Answer
Correct answer: A — info()
- What is the output of df.info()?
View Answer
Correct answer: A — Column info
- Which function selects rows by condition?
View Answer
Correct answer: A — loc[]
- What will be printed?
1 python 2 import pandas as pd 3 df = pd.DataFrame({"Eduinq":[1,2,3]}) 4 print(df.loc[df["Eduinq"]>2]) View Answer
Correct answer: A — Row with 3
- Which function selects rows by index position?
View Answer
Correct answer: A — iloc[]
- What is the output of df.iloc[0]?
View Answer
Correct answer: A — First row
- Which function merges DataFrames?
View Answer
Correct answer: A — merge()
- What will be printed?
1 python 2 import pandas as pd 3 df1 = pd.DataFrame({"id":[1],"val":["E"]}) 4 df2 = pd.DataFrame({"id":[1],"val":["duinq"]}) 5 print(pd.merge(df1,df2,on="id")) View Answer
Correct answer: A — Merged DataFrame
- Which function concatenates DataFrames?
View Answer
Correct answer: A — concat()
- What is the output of pd.concat([df1,df2])?
View Answer
Correct answer: A — Combined rows
- Which function joins DataFrames?
View Answer
Correct answer: A — join()
- What will be printed?
1 python 2 import pandas as pd 3 df1 = pd.DataFrame({"Eduinq":[1]},index=["A"]) 4 df2 = pd.DataFrame({"Eduinq":[2]},index=["B"]) 5 print(df1.join(df2,lsuffix="_1",rsuffix="_2")) View Answer
Correct answer: A — Joined DataFrame
- Which function groups data in Pandas?
View Answer
Correct answer: A — groupby()
- What is the output of df.groupby("Eduinq").size()?
View Answer
Correct answer: A — Group counts
- Which function creates pivot table?
View Answer
Correct answer: A — pivot_table()
- What will be printed?
1 python 2 import pandas as pd 3 df = pd.DataFrame({"A":[1,2,1],"B":[3,4,5]}) 4 print(df.pivot_table(values="B",index="A",aggfunc="mean")) View Answer
Correct answer: A — Mean grouped by A
- Which function fills missing values?
View Answer
Correct answer: A — fillna()
- What is the output of df.fillna(0)?
View Answer
Correct answer: A — Missing replaced with 0
- Which function drops missing values?
View Answer
Correct answer: A — dropna()
- What will be printed?
1 python 2 import pandas as pd 3 df = pd.DataFrame({"Eduinq":[1,None,3]}) 4 print(df.dropna()) View Answer
Correct answer: A — Rows without None
- Which function replaces values?
View Answer
Correct answer: A — replace()
- What is the output of df.replace(1,"E")?
View Answer
Correct answer: A — 1 replaced with E
- Which function converts DataFrame to NumPy array?
View Answer
Correct answer: A — to_numpy()
- What will be printed?
1 python 2 import pandas as pd 3 df = pd.DataFrame({"Eduinq":[1,2,3]}) 4 print(df.to_numpy()) View Answer
Correct answer: A — [[1],[2],[3]]