Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Best Way to Take Values from a Numpy Array, Two at a Time

$
0
0
I need suggestions for a way to take values from an array I built. I need to take them two rows at a time and be able to access each element of the two rows individually.

import numpy as np

'''
Created on Jan 27, 2013

@author:
'''


f ='/Users/Documents/workspace/findMinMax/crapc.txt'
x,y,z = np.loadtxt(f, unpack=True, usecols=(1,2,3), ndmin = 2)
  
maxZ = max(z)
minZ = min(z)
print("Maximum Z value: " + str(maxZ))
print("Minimum Z value: " + str(minZ))
    
zIncrement = .5
steps = maxZ/zIncrement
currentStep = .5

matrix = [x,y,z]  
[[row[i] for row in matrix] for i in range(3)]
#print(matrix[2][3])
print()

for i in matrix:
    
    print(i[2]) 


This works for printing each element, but it works in [column][row]. I have attached the file I'm working on

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>