Use value_counts
with normalize=True
:
df['gender'].value_counts(normalize=True) * 100
The result is a fraction in range (0, 1]. We multiply by 100 here in order to get the %.
More Related Contents:
- Get statistics for each group (such as count, mean, etc) using pandas GroupBy?
- Aggregation in Pandas
- Groupby value counts on the dataframe pandas
- Converting a Pandas GroupBy output from Series to DataFrame
- Multiple aggregations of the same column using pandas GroupBy.agg()
- Pandas groupby mean – into a dataframe?
- Python Pandas max value in a group as a new column
- How to loop over grouped Pandas dataframe?
- How to access pandas groupby dataframe by key
- Pandas Groupby and Sum Only One Column
- How to drop duplicates based on two or more subsets criteria in Pandas data-frame
- Python Pandas Group by date using datetime data
- Pandas – dataframe groupby – how to get sum of multiple columns
- Group dataframe and get sum AND count?
- How to summarize on different groupby combinations?
- get first and last values in a groupby
- Pandas groupby and aggregation output should include all the original columns (including the ones not aggregated on)
- Get the row corresponding to the max in pandas GroupBy [duplicate]
- Get frequency of item occurrences in a column as percentage [duplicate]
- How to get number of groups in a groupby object in pandas?
- When is it appropriate to use df.value_counts() vs df.groupby(‘…’).count()?
- Filter pandas DataFrame by substring criteria
- Binning a column with Python Pandas
- Pandas GroupBy.apply method duplicates first group
- Remove reverse duplicates from dataframe
- How to split text in a column into multiple rows
- How to flatten a pandas dataframe with some columns as json?
- Python – Delete duplicates in a dataframe based on two columns combinations?
- Scraping dynamic data selenium – Unable to locate element
- How to efficiently assign unique ID to individuals with multiple entries based on name in very large df