Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load a CSV file into a pandas DataFrame.
ML Python
import pandas as pd data = pd.read_csv([1])
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file name.
Passing the function call itself as argument.
✗ Incorrect
The file path must be a string inside quotes when using pd.read_csv().
2fill in blank
mediumComplete the code to load the Iris dataset from sklearn.
ML Python
from sklearn import datasets iris = datasets.[1]()
Attempts:
3 left
💡 Hint
Common Mistakes
Using fetch_iris which does not exist.
Trying to access iris_data attribute.
✗ Incorrect
The correct function to load the Iris dataset is load_iris().
3fill in blank
hardFix the error in the code to load a CSV file with pandas and display the first 5 rows.
ML Python
import pandas as pd df = pd.read_csv('data.csv') print(df.[1]())
Attempts:
3 left
💡 Hint
Common Mistakes
Using df.first() which does not exist.
Using df.show() which is not a pandas method.
✗ Incorrect
The method to show the first 5 rows of a DataFrame is head().
4fill in blank
hardFill both blanks to load the digits dataset and get its data and target arrays.
ML Python
from sklearn import datasets digits = datasets.[1]() data = digits.[2]
Attempts:
3 left
💡 Hint
Common Mistakes
Using fetch_digits which is incorrect.
Accessing 'target' instead of 'data' for features.
✗ Incorrect
Use load_digits() to load the dataset and access the data attribute for features.
5fill in blank
hardFill all three blanks to load the wine dataset, get its features and labels.
ML Python
from sklearn.datasets import [1] wine = [1]() features = wine.[2] labels = wine.[3]
Attempts:
3 left
💡 Hint
Common Mistakes
Using fetch_wine which does not exist.
Mixing up 'data' and 'target' attributes.
✗ Incorrect
Use load_wine() to load the dataset, then access 'data' for features and 'target' for labels.
