3 ms·
This is very Pandas specific, but I’m going to give you my intuition with a bit of Python knowledge (10yrs): 1. Anything that doesn’t have parens is either an
by bobwaycott 8y ago
This is very Pandas specific, but I’m going to give you my intuition with a bit of Python knowledge (10yrs):
1. Anything that doesn’t have parens is either an attribute or a property. A property is basically an attribute, except that a computation of some sort is usually executed to set/get its value, whereas an attribute has its value set explicitly. Look at the source to identify if the result of the first code block sets an attribute named `mean` or if it has an `@property` declaration named `mean`. Either way, they’re roughly the same when using them in code.
2. The fact that both `describe()` method examples can have another function and attribute/property chained to their result means `describe()` is returning an object of some type that is not a stdlib data type.
3. The `df.groupby().describe()` is likely returning a different type of object than the second `df.describe()`, as evidenced by the first result having a `mean` attr/property, while the second has a `mean()` function.
From here, I’d start by inspecting the object type returned by `df.groupby()`, `df.groupby().describe()`, and the `df.describe()` to discover the differences.