In Pandas, how do you access the first five rows of a DataFrame?
- df.head()
- df.iloc[:5]
- df.loc[:5]
- df[0:5]
To access the first five rows of a Pandas DataFrame, you should use the head() method, like df.head(). This method returns the top N rows (default is 5) of the DataFrame.
In Pandas, how can you filter the rows of a DataFrame where the value in a specific column is greater than a threshold?
- df.apply('column_name > threshold')
- df.filter('column_name > threshold')
- df.select('column_name').where('value > threshold')
- df[df['column_name'] > threshold]
To filter rows in a Pandas DataFrame where the value in a specific column is greater than a threshold, you can use boolean indexing. This is achieved by specifying the condition inside square brackets.
In Pandas, ____ is used to concatenate two or more DataFrames along a particular axis.
- combine
- concat
- join
- merge
In Pandas, the concat function is used to concatenate (combine) two or more DataFrames along a specified axis (either rows or columns). It is a powerful tool for combining data in various ways.
In object-oriented programming, ____ refers to the bundling of data and methods that operate on that data into a single unit.
- Abstraction
- Encapsulation
- Inheritance
- Polymorphism
In object-oriented programming, encapsulation refers to the concept of bundling data (attributes) and methods (functions) that operate on that data into a single unit, known as a class. This helps in data hiding and controlling access to an object's internals.
In object-oriented programming in Python, ____ refers to the class that a class inherits from.
- base class
- parent class
- subclass
- superclass
In Python, the term "base class" refers to the class that a class inherits from. It's also commonly called a "parent class" or "superclass."
In NumPy, the ____ function is used to compute the inverse of a matrix.
- np.inverse()
- np.invert()
- np.linalg.inv()
- np.transpose()
In NumPy, the np.linalg.inv() function is used to compute the inverse of a matrix. This function is essential for various linear algebra operations in NumPy, such as solving linear equations.
In NumPy, the ____ function is used to calculate the element-wise maximum of two arrays.
- max
- maximize
- maximum
- min
In NumPy, the maximum function is used to calculate the element-wise maximum of two arrays. It returns a new array containing the element-wise maximum values from the input arrays.
In Matplotlib, the ____ method is used to set the labels of the x-axis.
- set_x_axis
- set_x_label
- set_xlabel
- x_labels
In Matplotlib, you use the set_xlabel method to set the label for the x-axis. This method allows you to specify the label that appears below the x-axis in your plot.
In Matplotlib, the ____ method is used to create a new figure object.
- create_figure
- figure
- new_figure
- plot
In Matplotlib, the figure method is used to create a new figure object. A figure object is like a canvas where you can add multiple subplots or axes to create complex plots with multiple elements. It is an essential step when working with Matplotlib.
In Matplotlib, the ____ function is used to add text annotations in arbitrary locations of the plot.
- annotate
- caption
- label
- text
In Matplotlib, the annotate function is used to add text annotations in arbitrary locations of the plot. These annotations can be used to provide additional information about data points, labels, or other details on the plot.
In Matplotlib, how do you add a title to a plot?
- plt.add_title()
- plt.plot_title()
- plt.set_title()
- plt.title()
In Matplotlib, you add a title to a plot using the plt.title() function. This function takes a string as an argument and sets it as the title of the plot. Titles are essential to provide context and information about the content of the plot.
In machine learning, ____ is a technique used to choose the hyperparameters for a given model.
- Cross-Validation
- Feature Engineering
- Gradient Descent
- Hyperparameter Tuning
Hyperparameter tuning is the process of selecting the optimal hyperparameters for a machine learning model to achieve the best performance. It is a crucial step in model development.