Explore essential skills for inspecting, manipulating, and visualizing data using Pandas and Matplotlib in Python, with examples inspired by real-world datasets. This quiz covers data preparation, code usage, and key plotting techniques.
Which method is used in Pandas to display concise information about a DataFrame's columns, data types, and non-null values?
Explanation: df.info() provides a summary of the DataFrame including column names, data types, and non-null counts, which helps in inspecting the dataset. df.head() shows the first few rows, df.plot() is used for visualizations, and df.describe() gives summary statistics for numerical columns.
What is the correct Pandas function to load a CSV file into a DataFrame for analysis?
Explanation: pd.read_csv() is the standard function for reading CSV files into a Pandas DataFrame. The other options are incorrect as they are not valid Pandas functions.
How can you check the number of rows and columns in a Pandas DataFrame named 'df'?
Explanation: df.shape returns a tuple representing the number of rows and columns. df.size() gives the total number of elements, df.count() returns non-null value counts per column, and df.length() is not a valid DataFrame method.
Which command creates a line plot of new cases over time using Matplotlib with data in columns 'Date_reported' and 'New_cases'?
Explanation: plt.plot(x, y) is the basic Matplotlib line plot function, here with dates on x and new cases on y. plt.bar() creates a bar chart, df.plot.line() requires specifying axes differently, and plt.line() is not a valid Matplotlib function.
What is the correct way to set the default figure size to 20x10 inches in Matplotlib before creating a plot?
Explanation: plt.rcParams['figure.figsize'] = (20, 10) sets the default figure size for all subsequent plots. The other options either use incorrect method names or syntax not found in Matplotlib.