'Changing column name and finding mean and standard deviation in Spyder (Python 3.9.7)

I'm working on a project for class, and y'all have been so incredibly helpful!

Anyways, I used this code:

SO21= BI21[BI21["OnHand"].eq(0)].groupby("BrandID")["InventoryDate"].nunique()

And it generated this series (please bare with me I'm still learning how to best input my information here for you to see):

enter image description here

I then wanted to find the sum, mean, standard deviation, and standard error and used this code that we learned in class:

SOSummary19 = SO19["InventoryDate"].agg(["sum","mean","std","sem"])

It returns a KeyError: "InventoryDate'

My goal is to take those measurements based on the numbers in the 'InventoryDate' Column from the image I posted, and I would also like to rename 'InventoryDate' to 'DaysStockedOut'

Thank you in advance for your help, you are ALL amazing!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source