Your code works, but it’s not officially supposed to.
pd.crosstab(penguins.species, "count")
This runs fine, but according to the documentation, the second argument (columns) should be a list, array, or Series not a string.
Why it works anyway?
When you pass "count", Pandas internally converts it like this:
np.asarray("count") → becomes array(['c', 'o', 'u', 'n', 't'])
(an array of letters!)
Pandas then broadcasts this value, effectively treating it as if you had given a single constant column.
So it behaves as if you wrote:
pd.crosstab(penguins.species, pd.Series(["count"] * len(penguins)))
That’s why you get a single column called count showing the number of rows for each species.