Replace the extreme value with percentile with DolphinDB update statement?

Viewed 17

I want to replace the value in the perform column that is less than the 5th percentile with 5th percentile. Can I use the following to achieve?

update ljdata set perform=percentile(perform, 5) where perform<percentile(perform, 5)>

I have sample data percentile(perform, 5)=-15.77, but after executing this sentence, all the original values less than -15.77 are replaced by -61.38. How can I correct it? Thank you in advance for any help!

1 Answers

You can try the following code:

p5=exec percentile(perform, 5) from ljdata
update ljdata set perform=p5 where perform <p5

The problem is that where statement is executed before update. When the percentile is calculated, it is not the original data, but the remaining data involved in calculation.

Related