How to pretty-print a numpy.array without scientific notation and with given precision?

后端 未结 14 2356
臣服心动
臣服心动 2020-11-22 04:28

I\'m curious, whether there is any way to print formatted numpy.arrays, e.g., in a way similar to this:

x = 1.23456
print \'%.3f\' % x
         


        
14条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 04:48

    And here is what I use, and it's pretty uncomplicated:

    print(np.vectorize("%.2f".__mod__)(sparse))
    

提交回复
热议问题