Title: How to create a pie chart from a text column data only using pandas dataframe directly?
Tags: pandas;dataframe
Question: I have a csv file which I read using
pd.read_csv()
In the file name I have a column with Female or Male and I would like to create a pie visualization Female or Male. This means, my legend will contain the color and type ( Female or Male) and in the pie chart, there will be the Prozent of each gender.
An example of a data set will be:
['Female', 'Female', 'Female', 'Male', 'Male', 'Female']
A possible solution is to count the number of Female and the number of Male and then to generate the ṕlot.
Is there a simpler way using the dataframe data directly to generate the pie chart?
Comment: https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples

Here is the accepted answer: s = pd.Series(['Female', 'Female', 'Female', 'Male', 'Male', 'Female'])
s.value_counts(normalize=True).plot.pie(autopct='%.1f %%', ylabel='', legend=True)


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:02/08/21', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<pandas><dataframe>', 'Title': 'How to create a pie chart from a text column data only using pandas dataframe directly?', 'ViewCount': 332, 'id': 66108871, 'user_AboutMe': 'Program in C++ (newbie), C (newbie), Perl (newbie) and Matlab', 'user_AccountId': 81714.0, 'user_DisplayName': 'Eagle', 'user_Reputation': 3176.0, 'user_Views': 243.0, 'user_id': 230270.0}}