Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
480 views
in Technique[技术] by (71.8m points)

pandas - Plot the distribution of values in a column based on category in another column

I have two columns of data as indicated below:

data = {'labels': {0: '00',
  1: '08',
  2: '00',
  3: '08',
  4: '5',
  5: '04',
  6: '08',
  7: '04',
  8: '08',
  9: '5',
  10: '5',
  11: '04',
  12: '5',
  13: '00',
  14: '08',
  15: '5',
  16: '00',
  17: '00',
  18: '04',
  19: '04'},
 'scores': {0: 0.0023585677121699122,
  1: 0.056371229170055104,
  2: 0.005376756883710199,
  3: 0.05694460526172507,
  4: 0.1049131006122696,
  5: 0.008102266910447686,
  6: 0.09154342979296892,
  7: -0.03761723194472211,
  8: 0.010718527281161072,
  9: 0.11988838522095685,
  10: 0.09070139731152083,
  11: 0.02994813107318378,
  12: 0.09277903598030868,
  13: 0.062223925985664286,
  14: 0.1377963110579728,
  15: 0.11898618005936024,
  16: -0.021227109409528988,
  17: 0.008938944493717238,
  18: 0.03413068403999525,
  19: 0.058688416622356965}}

df = pd.DataFrame(data)

I want am trying to plot the values in the scores and color it according to the labels. I have tried

sns.scatterplot(data=df,x='labels',y='scores');

This works but it doesn't show the clusters(each x value is separated) as shown here enter image description here

I want the points to be in the same space and colored differently according to the df['labels'].

question from:https://stackoverflow.com/questions/65842115/plot-the-distribution-of-values-in-a-column-based-on-category-in-another-column

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...