I am trying to figure out the code to generate a table that shows average retail price, average wholesale price, and the average market share. I am being asked to use df
and groupby
]
The image shows the gas stations I am looking at and lists the name, ID, Address, Latitude, Longitude, date, Price, Wholesale, Tax, mkshare, and brand.
IIUC this is what you want:
df.groupby("Name")[["Price", "Wholesale", "mkshare"]].mean()
Basically, you have to group by the gas stations names, select the necessary columns and get the mean of them.
It's always good to take a look at the documentation: