CARVIEW |
Python Numpy Quiz
Question 1
How can you calculate the element-wise square root of a NumPy array arr?
np.sqrt(arr)
arr.sqrt()
np.square_root(arr)
arr.square_root()
Question 2
Question: How can you save a Pandas DataFrame to a CSV file?
df.save_csv("filename.csv")
df.write_csv("filename.csv")
df.to_csv("filename.csv")
df.export_csv("filename.csv")
Question 3
How can you perform a time-based resampling in Pandas?
df.resample()
df.time_resample()
df.groupby("time_column").resample()
df.time_groupby().resample()
Question 4
What is the purpose of the melt() function in Pandas?
To melt a DataFrame into a longer format
To create a melted cheese plot
To melt a DataFrame into a wider format
To melt a DataFrame into a binary format
Question 5
How can you handle duplicate values in a Pandas DataFrame?
Use the df.drop_duplicates() method
Use the df.remove_duplicates() method
Use the df.drop_duplicate_rows() method
Use the df.eliminate_duplicates() method
Question 6
How can you handle missing values in a Pandas DataFrame?
Use df.fillna(value) to replace missing values
Use df.dropna() to remove rows with missing values
Both A and B
Neither A nor B
Question 7
How can you merge two DataFrames in Pandas?
df.concat()
df.join()
df.merge()
df.combine()
Question 8
Write code to normalize a NumPy array arr by scaling its values to be between 0 and 1.
normalized_arr = (arr - arr.min()) / (arr.max() - arr.min())
normalized_arr = np.scale(arr)
normalized_arr = arr.normalize()
normalized_arr = (arr - arr.mean()) / arr.std()
Question 9
How can you calculate the mean along a specific axis of a 2D NumPy array arr?
mean_values = np.mean(arr, axis=1)
mean_values = arr.mean(axis=0)
mean_values = np.average(arr, axis=1)
mean_values = arr.mean(axis=2)
Question 10
Write code to find the intersection of two NumPy arrays a and b.
intersection = np.intersect(a, b)
intersection = np.common(a, b)
intersection = np.intersect1d(a, b)
intersection = a.intersection(b)
There are 25 questions to complete.