Hakuna matata
Hakuna matata

Reputation: 33

How can I round an array of arrays? I tried already numpy.round

[[391.88096195], [386.44174122], [378.13177006], [368.87926224]]

My output is the above array of arrays, and I want to round it like:

[[391.88], [386.44], [378.13], [368.87]]

Upvotes: 1

Views: 271

Answers (1)

napuzba
napuzba

Reputation: 6288

You can use the list comprehension syntax:

>>> arr = [[391.88096195], [386.44174122], [378.13177006], [368.87926224]]
>>> arr = [[round(xx,2) for xx in aa] for aa in arr]
[[391.88], [386.44], [378.13], [368.87]]

Upvotes: 1

Related Questions