简体   繁体   中英

Code snippet from R to Python for Panda dataframe graph plot

I am working with a panda data frame object. Till now I have uploaded and processed a data frame which looks like below: 熊猫数据框

The next step is I have to plot a graph with this data frame which will look like this图形

I have came across a R code snippet which will be helpfull in creating x-axis and y-axis for this graph

d_ends <- 
yearly_top %>% 
group_by(tag) %>% 
slice(n()) %>% 
pull(fraction)

d_ends[1] <- 0.053
d_ends[6] <- 0.024

d_labels <- 
yearly_top %>% 
group_by(tag) %>% 
slice(n()) %>% 
pull(tag)

I am trying to convert this in Python. Any idea would really be great

Take a look at seaborns lineplot . It's a great package for this kind of plotting:

import seaborn as sns
sns.lineplot(data=yearly_top, x='year', y='fraction', hue='tag')

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