Course materials Github: https://github.com/machinelearningplu... ----------------------------------------- Iterating becomes important when you are working on Machine Learning model. This is actually an iterable object, which means you can iterate through it using a for loop. 🔹 Why Does Everyone Like Iterating Between Groups in Pandas? Now doing a group by on data frame creates a data frame group by object. This is actually an iterable object, which means you can iterate through it using a for loop. So when is this useful if you want to do further customized operations, more complex operations, and you are not very clear what sort of function whether you need to use an add function or an apply functions you are not clear on what sort of function to use to do this operation, you can simply write a for loop on top of this object, and do whatever sort of customization that you want to do. Let me state a simple example. For example, you want to compute the mean fare for every class. In the same Titanic data frame for every class over here, you want to compute the mean fare, but while computing it, you want to exclude all the zero fares for male passengers in the second class. This is a small customization to the logic right. Now you can do this logic using the apply function itself, do a group by and then do you use apply and then compute this logic, right, but then to write that apply function, you need to do a little bit more thinking on how that will work, right? Instead of going that route. If you want to keep it simple, you can directly write a for loop So first, what I'm doing here is I'm importing NPN, pandas importing the data set doing the group by on p class, if you look at the type of this particular object, it is a data frame group by object. #machinelearningplus #python #pandasdatascience Let me know in the comments section if you have any questions! If you enjoyed this video, be sure to throw it a like and make sure to subscribe to not miss any future videos! Thanks for watching!