Lets understand the code from scratch
This function is used to create a pivot table.
In this function, you are using “Outlet_Type” as column and “Outlet_Size” as values.
Now for aggregation of the values, you are using mode of the “Outlet_Size” for each group in pivot. The steps you are using are
- drop NA values in the group if there are any
- Take the mode of that group of values
- Take mode again to get a single output
To check what is going on internally, I would recommend you to break down the code, and apply each step iteratively to understand what occurs under the hood