Reputation: 1256
How can I write this syntax if there was space in the column name "image_path"? Instead of "image_path", I have "image path". I changed the column name so it works. However, I was wondering if there is any way I can write this syntax without changing column name from "image path" to "image_path".
(df.groupby('content_type').image_path.nunique())
Thank you, Shone
EDIT: Just in case the answer below is deleted:
df.groupby('content_type')['image path'].nunique()
Upvotes: 1
Views: 138
Reputation: 402553
Use the [...]
indexer with a string:
df.groupby('content_type')['image path'].nunique()
Upvotes: 4