简体   繁体   中英

Pandas count unique value and change to percentage and put into the plotly bar chart

I have a pandas dataframe which looks like this:

Country  
 Japan   
 Japan   
 Korea   
 India   
 India   
  USA    
  USA    
  USA   

I need to count the unique values of the country column and change to percentage and need to put in the x-axis and y-axis of plotly bar chart. Can anyone teach me how to do it?

使用value_counts

df.Country.value_counts(normalize=True)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM