r/learnpython•
PascP

I'm translating Matlab code to Python (size -> shape)

I'm translating Matlab code to Python and I came to this

t = size(data,1);

where data is an array. In python, I "translated" it to

if data.ndim==1:
    t=1
else:
    t = data.shape[0]

Is there a better way.

Posted Aug 17, 2017, 7:43 PM UTC

210
Loading comments…