三列时最大的五个数字
a) 当ID重复时如何找到最大的5个SNR?我还希望所有这三列作为输出。 b)我还希望消除的行作为输出。
FIT ID SNR
1011563.fit, J16142485-3141000 , 36
1011729.fit, J17210134-3757437 , 18
1011730.fit, J17210134-3757437 , 20
1011731.fit, J17210134-3757437 , 20
1011732.fit, J17210134-3757437 , 13
1011914.fit, J17210134-3757437 , 38
1011915.fit, J17210134-3757437 , 26
1011916.fit, J17210134-3757437 , 19
1011917.fit, J17210134-3757437 , 47
1011918.fit, J17210134-3757437 , 25 ´´´
Expected output for a.
FITS ID SNR
```8 1011917.fit J17210134-3757437 47
5 1011914.fit J17210134-3757437 38
0 1011563.fit J16142485-3141000 36
6 1011915.fit J17210134-3757437 26
9 1011918.fit J17210134-3757437 25
2 1011730.fit J17210134-3757437 20 ´´´
Output b)
``` FITS ID SNR
1 1011729.fit J17210134-3757437 18
6 1011915.fit J17210134-3757437 26
7 1011916.fit J17210134-3757437 19
8 1011917.fit J17210134-3757437 47´´´
As you can see SNR "6 1011915.fit J17210134-3757437 26" and
"8 1011917.fit J17210134-3757437 47" are repeated. But I want this only as output a and not b.
a) How to find the largest five SNRs when the ID is repeated? And also I want all these three columns as the output.
b) I also want the eliminated lines as the output.
FIT ID SNR
1011563.fit, J16142485-3141000 , 36
1011729.fit, J17210134-3757437 , 18
1011730.fit, J17210134-3757437 , 20
1011731.fit, J17210134-3757437 , 20
1011732.fit, J17210134-3757437 , 13
1011914.fit, J17210134-3757437 , 38
1011915.fit, J17210134-3757437 , 26
1011916.fit, J17210134-3757437 , 19
1011917.fit, J17210134-3757437 , 47
1011918.fit, J17210134-3757437 , 25 ´´´
Expected output for a.
FITS ID SNR
```8 1011917.fit J17210134-3757437 47
5 1011914.fit J17210134-3757437 38
0 1011563.fit J16142485-3141000 36
6 1011915.fit J17210134-3757437 26
9 1011918.fit J17210134-3757437 25
2 1011730.fit J17210134-3757437 20 ´´´
Output b)
``` FITS ID SNR
1 1011729.fit J17210134-3757437 18
6 1011915.fit J17210134-3757437 26
7 1011916.fit J17210134-3757437 19
8 1011917.fit J17210134-3757437 47´´´
As you can see SNR "6 1011915.fit J17210134-3757437 26" and
"8 1011917.fit J17210134-3757437 47" are repeated. But I want this only as output a and not b.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在排序后的数据帧上使用
groupby
+head
来获取索引,然后切片:输出:
其他行:
输出:
Use
groupby
+head
on the sorted dataframe to get the indices, then slice:output:
Other rows:
output: