Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy move columns

>>> import numpy as np
>>> a = np.array([[10, 20, 30, 40, 50],
...               [ 6,  7,  8,  9, 10]])
>>> permutation = [0, 4, 1, 3, 2]
>>> idx = np.empty_like(permutation)
>>> idx[permutation] = np.arange(len(permutation))
>>> a[:, idx]  # return a rearranged copy
array([[10, 30, 50, 40, 20],
       [ 6,  8, 10,  9,  7]])
>>> a[:] = a[:, idx]  # in-place modification of a
Comment

PREVIOUS NEXT
Code Example
Python :: Python logging comma to dot 
Python :: int and text on same line python 
Python :: supervisor gunicorn virtualenv flask 
Python :: configparser error reading relative file path 
Python :: np.apply_along_axis third dimension python 
Python :: python web app with redis github 
Python :: python get function from string name 
Python :: dinoscape für pc 
Python :: sumif in python on a column and create new column 
Python :: voting classifier with different features 
Python :: python dijkstra implementation stack 
Python :: python in a nutshell 
Python :: spark dataframe without column 
Python :: response object has no code 
Python :: Percentage change between the current and the prior element. 
Python :: panda3d attach to bone 
Python :: discord.py get channel object from id 
Python :: repeats in python 
Python :: python multiprocessing queu empty error 
Python :: list in pythom 
Python :: mongoengine ObjectIdField 
Python :: poython inl linrt dor loop 
Python :: mechanize python #12 
Python :: check firebase email 
Python :: example of python application from github to docker image 
Python :: time vs timeit 
Python :: how to draw tony stark sketch in python 
Python :: pyton 
Python :: pyttsx3 Running a driver event loop 
Python :: Command to import Required, All, Length, and Range from voluptuous 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =