Note that there are some explanatory texts on larger screens.

plurals
  1. PORanking CSV numbers in both ascending and descending orders in python
    primarykey
    data
    text
    <p>I'm surprised that I can't find anything about ranking numbers in python...</p> <p>Basically, I'm in need of two scripts to do the same task just one in an ascending order and one in a descending order.</p> <p><strong><code>row[2]</code> is the numbers to be ranked, <code>row[4]</code> is the cell to put the rank into.</strong></p> <p><strong><code>row[0] + row[1]</code> is what defines each dataset/group</strong></p> <p>In this first example the larger numbers have the higher rank.</p> <h3>CSV Example 1 (Ranks Down)</h3> <pre><code>uniquedata1,uniquecell1,42,data,1,data uniquedata1,uniquecell1,32,data,2,data uniquedata1,uniquecell1,13,data,3,data uniquedata2,uniquecell2,41,data,2,data uniquedata2,uniquecell2,39,data,3,data uniquedata2,uniquecell2,45,data,1,data uniquedata2,uniquecell2,22,data,4,data uniquedata1,uniquecell2,36,data,3,data uniquedata1,uniquecell2,66,data,1,data uniquedata1,uniquecell2,40,data,2,data </code></pre> <p>In this second example the larger numbers have the lower rank.</p> <h3>CSV Example 2 (Ranks Up)</h3> <pre><code>uniquedata1,uniquecell1,42,data,3,data uniquedata1,uniquecell1,32,data,2,data uniquedata1,uniquecell1,13,data,1,data uniquedata2,uniquecell2,41,data,3,data uniquedata2,uniquecell2,39,data,2,data uniquedata2,uniquecell2,45,data,4,data uniquedata2,uniquecell2,22,data,1,data uniquedata1,uniquecell2,36,data,1,data uniquedata1,uniquecell2,66,data,3,data uniquedata1,uniquecell2,40,data,2,data </code></pre> <p>In this third example, which is ranking up it includes empty cells which should be given the highest ranks (if there are two blanks they should be given the same rank)</p> <h3>CSV Example 3 (Includes empty cells)</h3> <pre><code>uniquedata1,uniquecell1,42,data,2,data uniquedata1,uniquecell1,,data,3,data uniquedata1,uniquecell1,13,data,1,data uniquedata2,uniquecell2,41,data,3,data uniquedata2,uniquecell2,,data,3,data uniquedata2,uniquecell2,,data,3,data uniquedata2,uniquecell2,22,data,1,data uniquedata1,uniquecell2,36,data,1,data uniquedata1,uniquecell2,66,data,3,data uniquedata1,uniquecell2,40,data,2,data </code></pre> <p>Anyone know how to I can achieve my intended result?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload