So if i wanted to get the count and store it as a variable z. I know I can do something like df.describe().loc['count'] but i am unable to extract the number to variable z itself to do mathematical operations like addition.
CodePudding user response:
Pandas describe method returns a Series or a DataFrame.
So, you can extract and assign any specific value like this (although it is easier to use the corresponding method, as suggested by @tdy):
z = df.describe().loc["50%"].tolist()[0]
print(type(z)) # <class 'float'>