Skip to content
Advertisement

how to get .value_count and values in single data frame

This is my sample csv

JavaScript

When I do .value_counts() I get

JavaScript

I want to get

JavaScript

This is my current attempt

JavaScript

This does not concat the two df properly and does not have the ID

Any suggestions?

Advertisement

Answer

You can use a groupby.agg in place of value_counts:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement