
Explanation:
Databricks provides several widget types for interactive data analysis: text, dropdown, combobox, and multiselect. The dropdown widget is ideal for selecting a single value from a predefined list, which matches the requirement here. The correct usage involves specifying the widget name, default value, and the list of options. The current value can then be retrieved using dbutils.widgets.get("country"). Therefore, the correct answer is the option using dbutils.widgets.dropdown.
Ultimate access to all questions.
A data analyst is tasked with performing exploratory data analysis on weather data across multiple countries. She needs to select a single country's name at a time, assign it to a Python variable for use as a parameter in a function processing that country's data, with 'India' as the default country. Which of the following code blocks accomplishes this task?
A
dbutils.widgets.list("country", "India", ["India", "Canada", "England", "USA"])current_country = dbutils.widgets.get("country")
B
dbutils.widgets.dropdown("country", "India", ["India", "Canada", "England", "USA"])current_country = dbutils.widgets.get("country")
C
dbutils.widgets.options("country", "India", ["India", "Canada", "England", "USA"])current_country = dbutils.widgets.get("country")
D
dbutils.widgets.select("country", "India", ["India", "Canada", "England", "USA"])current_country = dbutils.widgets.get("country")
E
dbutils.widgets.checkbox("country", "India", ["India", "Canada", "England", "USA"])current_country = dbutils.widgets.get("country")
No comments yet.