Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left
Apply NowLogin using Social Account
     Continue with GoogleLogin using your credentials
Finally, we use the loc() attribute of the DataFrame object to access the DataFrame by training and testing index. Its syntax is-
df_name.loc[indices]
where df_name is the name of our DataFrame object and indices can be a single index or an array-like. In our case it is array-like.
Call the loc() attribute on our DataFrame housing providing train_ind and test_ind as indices for generating the training and testing dataset. Store the training data in a variable strat_train_set and testing data in a variable strat_test_set.
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Loading comments...