Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sort array python by column

Sorting a NumPy array by a column orders its rows based 
on the ordering of the values in the column. 
For example, sorting the array [[8 2 -2] [-4 1 7] [6 3 9]] 
by its second column returns [[-4 1 7] [8 2 -2] [6 3 9]].
USE numpy.args

sorted_array = an_array[numpy.argsort(an_array[:, 1])]
Comment

PREVIOUS NEXT
Code Example
Python :: how to check python version in cmd 
Python :: python version check 
Python :: python filter a dictionary 
Python :: download pdf using python 
Python :: sns legend outside 
Python :: pyspark dataframe to single csv 
Python :: csv write without new line 
Python :: python remove a key from a dictionary 
Python :: how to create data dictionary in python using keys and values 
Python :: python file name from absolute path 
Python :: find duplicate in dataset python 
Python :: convert excel to csv using python 
Python :: tkinter app icon 
Python :: message tags in django 
Python :: how can I plot model in pytorch 
Python :: how to find duplicate numbers in list in python 
Python :: python multiply one column of array by a value 
Python :: createview django 
Python :: pyinstaller 
Python :: resample python numpy 
Python :: remove empty strings from list python 
Python :: reverse string in python 
Python :: python datetime without seconds 
Python :: python transform two columns to a list combine 
Python :: termcolor python 
Python :: zlib decompress python 
Python :: how to count number of unique values in a column python 
Python :: pd merge on multiple columns 
Python :: how to make random colors in python turtle 
Python :: python - removeempy space in a cell 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =