반응형

numpy 배열의 데이터를 원본 csv 파일에서 찾을 목적으로 만들었던 코드였는데 간단한 데이터로 예제코드를 만들어봤습니다. 

 

2021. 9. 11 최초작성




import numpy as np 


a = np.linspace(0.01, 1.00, 9).reshape(3, 3)

print('original')
print(a)
print()

print('new')
np.set_printoptions(suppress=True)
print('\n'.join(','.join(str(format(cell,"0.3f")) for cell in row) for row in a))

 

original
[[0.01    0.13375 0.2575 ]
 [0.38125 0.505   0.62875]
 [0.7525  0.87625 1.     ]]

new
0.010,0.134,0.258
0.381,0.505,0.629
0.752,0.876,1.000




참고

 

https://stackoverflow.com/questions/9829348/how-to-print-numpy-arrays-without-any-extra-notation-square-brackets-and-sp 

 

https://stackoverflow.com/questions/16423774/string-representation-of-a-numpy-array-with-commas-separating-its-elements 

 

https://www.kite.com/python/answers/how-to-print-a-numpy-array-without-scientific-notation-in-python 

 

https://andamiro25.tistory.com/16 



반응형

문제 발생시 지나치지 마시고 댓글 남겨주시면 가능한 빨리 답장드립니다.

도움이 되셨다면 토스아이디로 후원해주세요.
https://toss.me/momo2024


제가 쓴 책도 한번 검토해보세요 ^^

+ Recent posts