[SciPy-User] pandas: independent row sorting of data frame

Fabrizio Pollastri f.pollastri at inrim.it
Mon Jan 3 06:28:10 EST 2011


Hello,

I am trying to convert the following R code to python + pandas. The code sort
independently each row of an xts  multiseries (xs), obtaining a sorting index
and a sorted copy of the original multiseries.

sort_index = t(apply(as.matrix(coredata(xs)),1,order,decreasing=TRUE))
sorted_xs = t(apply(as.matrix(coredata(xs)),1,sort,decreasing=TRUE))

Playing with pandas data frame, I found the equivalent statement for sort_index:

sort_index = df.tapply(argsort)

What is the equivalent to obtain a sorted copy?


TIA,
Fabrizio Pollastri




More information about the SciPy-User mailing list