Python Forum
how to select particular rows data from a array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to select particular rows data from a array
#1
I am new programmer to python. 
I have a text file having 360 rows and 190 columns of data. 
In matlab, if I load the text file and x_data will be variable of size 360x190 columns.
If I want to select 1 to 20 , 46 to 65, ... rows of data , I simply give 
x_data_train = xdata([1:20,46:65,91:110,136:155,181:200,226:245,271:290,316:335], :);
the resulting x_data_train will be the array of my desired. 

How can do that in python ? 


x_data = np.loadtxt('dataset_300mm.txt', unpack=True)
x_data_train = []
x_data_train.append(x_data[1:20],
                   x_data[46:65],
                   x_data[91:110],
                   x_data[136:155],
                   x_data[181:200],
                   x_data[226:245],
                   x_data[271:290],
                   x_data[316:335])
if I do using append operation , the resultant of the array is strange , it is array of 8 subsets of array for 20*192, but I want it to be one array 160*192
Reply


Messages In This Thread
how to select particular rows data from a array - by raady07 - Mar-04-2017, 03:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dropping Rows From A Data Frame Based On A Variable JoeDainton123 1 326 Aug-03-2020, 02:05 AM
Last Post: scidam
  Adding data in 3D array from 2D numpy array asmasattar 0 424 Jul-23-2020, 10:55 AM
Last Post: asmasattar
  How to shift data frame rows of specified column Mekala 0 496 Jul-21-2020, 02:42 PM
Last Post: Mekala
  Filter rows by multiple text conditions in another data frame i.e contains strings an Pan 0 503 Jun-09-2020, 06:05 AM
Last Post: Pan
  Select column between to dates CSV data PythonJD 0 435 Apr-14-2020, 12:22 PM
Last Post: PythonJD
  Read json array data by pandas vipinct 0 394 Apr-13-2020, 02:24 PM
Last Post: vipinct
  How can I convert time-series data in rows into column srvmig 0 390 Apr-11-2020, 05:40 AM
Last Post: srvmig
  Creating look up table/matrix from 3d data array chai0404 3 543 Apr-09-2020, 04:53 AM
Last Post: buran
  Select data from between two timestamps Makada 18 1,758 Feb-07-2020, 09:56 AM
Last Post: Makada
  Identifying consecutive masked values in a 3D data array chai0404 12 1,394 Feb-01-2020, 12:59 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020