简体   繁体   中英

How to format this numpy array in this format?

I have a numpy array like this:

a = [[0.04393, 0.0, 0.0], [0.04393, 0.005, 0.0], [0.04393, 0.01, 0.0],[0.04393, 0.015, 0.0]]

And i want to format it in this:

b = [((0.04393, 0.0, 0.0), ), ((0.04393, 0.005, 0.0), ), ((0.04393, 
0.01, 0.0), ), ((0.04393, 0.015, 0.0), )]

How can i do it?

This will do:

a = [[0.04393, 0.0, 0.0], [0.04393, 0.005, 0.0], [0.04393, 0.01, 0.0],[0.04393, 0.015, 0.0]]
b = [ (tuple(a1),) for a1 in a]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM