Reputation: 11
I have Latitude and Depth, I want to seprate these two arrays in form of numpy array.
[['Latitude' 'Depth'] ['28.00303425' '5067.9097'] ['28.00304059' '5068.656'] ... ['28.01996016' '5067.0303'] ['28.01996016' '5067.0234'] ['28.01996017' '5066.8833']]
Upvotes: 0
Views: 46
Reputation: 166
Try this following code snippet. The zip command can be used to split the 2d array into two separate columns/arrays. I used the index "1:" to remove the top row, containing the column names.
data=np.asarray([['Latitude','Depth'],
['28.00303425','5067.9097'],
['28.00304059','5068.656'],
['28.01996017','5066.8833']])
lat, depth = zip(*data[1:])
print(np.asarray(lat))
print(np.asarray(depth))
Output
['28.00303425' '28.00304059' '28.01996017']
['5067.9097' '5068.656' '5066.8833']
Upvotes: 1