Get half of rows of column - Array slicing with python/pandas

Viewed 411

I would like to get exactly half of all rows in the first column.

tensor([[0.8831, 0.5263],
        [0.5528, 0.3027],
        [0.4942, 0.0996],
        [0.5346, 0.8010],
        [0.1299, 0.0558]
        [0.3020, 0.2002]])

I would like to select the first column like:

print(x[(0:-1,0])

The -1 will leave out the last entry out. I would like to add a +1.

print(x[(0:(-1+1),0])

And now I would like to divide it by 2 so I get exactly the half of the column.

print(x[(0:(-1+1)/2,0])

So that im getting:

tensor([0.8831, 0.5528, 0.4942])
0 Answers
Related