Any ideas what is equivalent to python for R order?
order
order(c(10,2,-1, 20), decreasing = F) # 3 2 1 4
Numpy has a function called argsort
argsort
import numpy as np lst = [10,2,-1,20] np.argsort(lst) # array([2, 1, 0, 3])
Note that the pit list index starts at 0, starting at 1 in R.
it numpy.argsort()
numpy.argsort()
import numpy a = numpy.array([10,2,-1, 20]) a.argsort() # array([2, 1, 0, 3])
and if you want to study the parameter decreasing = T. You can try,
decreasing = T
(-a).argsort() #array([3, 0, 1, 2])
Source: https://habr.com/ru/post/1653978/More articles:PrimeNG datatable checkbox paginated - angularМогу ли я отправить приложение Swift 2.2 с Xcode 7.3 при выпуске iOS 10? - ios10React-native: изображения, не отображаемые в устройстве Android; но отлично показывает в эмуляторе - androidThe minimum version of Xcode to download to the app store (as of February 2016) - iosHardcoded URLs - javascriptXcode console debugging output - iosCan I create Chocolatey packages on Linux? - chocolateyМогу ли я вставить кнопку внутри другой кнопки? - htmlHow to exit the Azure app? - authenticationHow to check the statistics of messages sent to topics through FCM? - firebaseAll Articles