小编bio*_*d90的帖子

How to plot a dot plot type scatterplot in matplotlib or seaborn?

Let's say I have a df like this:

df = pd.DataFrame({'col1': list('aabbb'), 'col2': [1, 3, 1, 5, 3]})

  col1  col2
0    a     1
1    a     3
2    b     1
3    b     5
4    b     3
Run Code Online (Sandbox Code Playgroud)

I would like to see a plot, where on the x axis, I have the col1 names ONCE, and on the y axis, the col2 data, as individual dots, so above 'a' I would have two dots at the height of 1 and 3, and …

python scatter matplotlib seaborn dot-plot

3
推荐指数
1
解决办法
6382
查看次数

如何获取pandas中连续值的比例?

假设我有以下 df:

col1|col2|col3
  1 |  3 |  1
  2 |  2 |  1
Run Code Online (Sandbox Code Playgroud)

我想要行的值的比例,所以 stg 像这样:

col1|col2|col3
 0.2| 0.6| 0.2
 0.4| 0.4| 0.4
Run Code Online (Sandbox Code Playgroud)

到目前为止,我的主要问题是如何获取行的总和:

mydf["col1_proportion"] = mydf["col1"].apply(lambda x: x / (XXX)  )  
Run Code Online (Sandbox Code Playgroud)

其中 (XXX) 应该是给定行的总和

python average row sum pandas

1
推荐指数
1
解决办法
235
查看次数

标签 统计

python ×2

average ×1

dot-plot ×1

matplotlib ×1

pandas ×1

row ×1

scatter ×1

seaborn ×1

sum ×1