0

I have some data (taken from a CSV file) in the format:

 MyValues = [[2 2 2 1 1]
             [2 2 2 2 1]
             [1 2 2 1 1]
             [2 1 2 1 2]
             [2 1 2 1 2]
             [2 1 2 1 2]
             [2 1 2 1 2]
             [2 2 2 1 1]
             [1 2 2 1 1]]

I would like to split this data into 2/3 and 1/3 and be able to distinguish between them. For example

twoThirds = [[2 2 2 1 1]
             [2 2 2 2 1]
             [1 2 2 1 1]
             [2 1 2 1 2]
             [2 1 2 1 2]
             [2 1 2 1 2]]

 oneThird = [[2 1 2 1 2]
             [2 2 2 1 1]
             [1 2 2 1 1]]

I have tried to use the following code to achieve this, but am unsure if i have gone about this the correct way?

   twoThirds = (MyValues * 2) / 3 #What does this code provide me?
ZeeeeeV
  • 361
  • 3
  • 11
  • 25
  • I am not certain of what you are asking. It looks like you are trying to slice the array. twoThirds, oneThird = MyValues[:len(MyValues)*2/3], MyValues[len(MyValues)*2/3:]. – Victor 'Chris' Cabral Feb 12 '13 at 20:01

1 Answers1

2

It's just a list, use the slice notation. And read the docs:

In [59]: l = range(9)

In [60]: l[:len(l)/3*2]
Out[60]: [0, 1, 2, 3, 4, 5]

In [61]: l[len(l)/3*2:]
Out[61]: [6, 7, 8]
root
  • 76,608
  • 25
  • 108
  • 120