Answer to main question:
import pyranges as pr
import numpy as np
np.random.seed(42 * 10)
# create large df to test on
gr = pr.random(int(1e5), length=1, chromsizes={"chr1": 249250621})
gr.Score = np.random.randint(250, shape=len(gr))
# function that does what you want
f = lambda df: df.loc[df.groupby("Cluster").Score.idxmax()]
# tada!
c = gr.cluster(slack=5000).apply(f)
# small example that is easy to validate
# if several hotspots, choose the one with the highest score
gr2 = pr.from_string("""Chromosome Start End Score
chr1 1 2 5
chr1 4999 5000 10
chr1 10001 10002 1
chr1 15000 15001 2
chr1 20100 20101 5
""")
gr2.cluster(slack=5000).apply(f)
# +--------------+-----------+-----------+-----------+-----------+
# | Chromosome | Start | End | Score | Cluster |
# | (category) | (int32) | (int32) | (int64) | (int32) |
# |--------------+-----------+-----------+-----------+-----------|
# | chr1 | 4999 | 5000 | 10 | 1 |
# | chr1 | 15000 | 15001 | 2 | 2 |
# | chr1 | 20100 | 20101 | 5 | 3 |
# +--------------+-----------+-----------+-----------+-----------+
# Unstranded PyRanges object has 3 rows and 5 columns from 1 chromosomes.
# For printing, the PyRanges was sorted on Chromosome.
Could you please post an example of what data you have and what you want to end up with?