1. 출처
https://numpy.org/doc/stable/reference/generated/numpy.set_printoptions.html
2. 코드
np.set_printoptions을 사용하여 surpress = True 로 주면된다.
import numpy as np
# e로 소수를 표현하지 않게 할때
np.set_printoptions(suppress=True)
a = np.random.randn(13,15)
a
array([[ 0.45719541, -1.90399834, 0.61248137, -1.16744861, -0.29408954, -0.62574659, -1.78635628, -0.98061967, -0.8956621 , -1.30789127, -0.84272643, 0.20106024, -0.56327799, 2.38778929, 0.30454435], [-0.29712473, 1.43960057, 0.97714701, 1.22958345, -1.5659555 , 0.01150854, 0.50803248, 0.5940914 , 1.42038007, 0.85675086, -1.97123971, -3.32667673, 0.93825696, 1.42448484, 0.14631831], [ 0.21648182, -2.94704857, -0.29189696, -2.84171311, -1.01747292, 2.590272 , -0.76013229, 0.36846173, -1.09405054, -0.8056928 , 0.88254476, 0.58711062, -1.38329995, -0.27111855, -1.97836378], [ 0.63615856, 0.50796104, 2.38841239, 1.5621561 , 1.65248389, -1.29641746, -0.98599761, -0.11650595, -0.2998004 , -0.59926906, 0.88811408, 0.48966094, 0.85494266, -0.81560581, 0.25413914], [-0.15001195, 0.18865524, -0.91598259, -1.56767329, 2.18015203, 0.45451694, 1.43124415, -0.85972499, 0.38948247, -0.0537188 , -0.49176471, -0.17541067, 1.00147251, -0.920051 , -1.06033048], [ 1.17440266, 1.13123995, -1.10505182, -0.99178631, 0.61545608, -0.17626816, 1.11924842, 0.28931398, 1.30775846, 0.2116786 , 0.6516992 , 2.01495558, 0.02918591, -0.29487736, -1.21465784], [-0.6523192 , 0.03155165, -0.40210912, -0.70793079, -1.28222929, -1.332858 , 1.36821628, -0.31666243, -2.33687431, -0.50792332, 0.6182724 , 1.10168188, 0.07730356, 0.89071327, -0.60136958], [ 0.33036 , -1.04852995, -1.13041644, 0.42140328, -0.87366619, 1.36198401, -1.09833019, 0.46719063, 0.13405883, 1.17301919, -1.21731108, -0.44277115, 0.52149847, -0.35500505, 2.58778384], [-0.29821151, 0.32675201, -1.4331891 , 0.83265349, 0.79403204, -0.68218471, -1.55073946, -1.04882161, -1.50202565, -0.43749078, -0.53304477, -0.17782105, 0.46970563, -1.11258565, -1.08368824], [-0.59567143, -1.17390726, -0.81332436, -0.97216612, 1.17895844, -0.46354912, -2.08799408, -3.00278898, -0.87850359, -0.07473568, 1.75480229, -1.3266149 , -0.3430493 , 0.74988047, -0.16774486], [ 0.03438863, -0.6361224 , 1.57466808, -1.12380245, -0.39280826, -2.63469787, 0.96311147, 0.92118142, 2.29030879, 0.38216702, -1.27833874, 0.87573914, 0.51804098, -0.31985921, -0.00995954], [ 0.31948486, 0.53145654, -0.22640883, 0.52813851, -0.20884011, -0.46352078, -0.83437078, 0.61115013, 0.28924188, 1.50668596, -1.6084017 , -1.21670997, -0.27602403, -1.43179953, -0.51346081], [ 1.50672433, 0.37234177, -1.67156391, -0.50952163, -0.91802663, 0.9391943 , 0.06110653, 1.13681559, -0.50747942, 0.28327879, -2.00934429, -0.52065715, 0.92634438, -0.57955734, 0.12097717]])
다시 True
import numpy as np
# e를 사용함
np.set_printoptions(suppress=False)
a = np.random.randn(13,15)
a
array([[-2.83652735e-01, 5.31075645e-02, -2.93354685e-01, -1.61760882e+00, 1.48465086e+00, 1.01661108e-01, 1.90968615e-01, 1.22362795e+00, 2.03775222e-01, -2.56823519e+00, -3.72030015e-01, 3.45999487e-01, -3.58759685e-01, 1.10101447e+00, 1.62355128e+00], [-7.06517932e-01, -1.74196582e-01, 5.55901766e-01, 7.43130691e-02, 3.68544581e-01, -4.36602104e-01, -2.72318905e-01, -3.82808586e-01, 1.01682236e+00, 3.58507889e-01, -1.28119887e+00, 6.31370738e-01, -1.20955544e+00, 5.81124257e-01, 1.13237405e+00], [-4.66496689e-03, 6.80660861e-02, 6.45192570e-01, 7.37999215e-01, -9.50973555e-01, 7.40211304e-02, 3.36555345e-01, -2.21842424e-01, -1.87203206e-02, 1.44156667e+00, -1.13605272e-02, 1.02468950e+00, 4.50439732e-01, -1.29210558e+00, 1.09235286e+00], [ 2.51142246e+00, -1.52633347e+00, 1.91054654e-01, 4.02330664e-01, -5.46260895e-01, 5.71510551e-01, 3.18440540e-01, -9.11159274e-01, -1.27337996e+00, -1.66501257e-01, 8.60026786e-01, 6.02086493e-02, 1.18417928e+00, -3.68675528e-01, 6.14432497e-01], [ 4.08929198e-01, 4.43636635e-01, 1.03959734e+00, 2.95703732e-02, 1.28141895e+00, 1.77742114e+00, -1.54248101e+00, -1.33346746e+00, 1.16106857e+00, 6.19329931e-01, 2.90170767e-02, 4.97534355e-01, -5.53743332e-01, 2.76745156e-01, -2.30812339e+00], [ 8.15717659e-01, -7.44013287e-01, 4.11601966e-01, -3.33264414e-01, -3.82777207e-02, 5.13089000e-01, 2.39367074e-01, -1.49838962e+00, 1.18335374e+00, 1.45698884e-01, -5.30979010e-01, 1.61839203e+00, 2.82972412e-01, -1.15183410e+00, -2.10817179e+00], [-4.91546825e-01, 7.68542167e-01, 3.12440590e-01, 4.77848558e-01, -9.29296168e-01, -1.63228109e-03, 4.25212486e-03, 1.19692057e+00, -8.72320739e-02, -4.35206866e-01, -1.70138599e+00, -3.81951277e-01, -1.34869202e+00, -2.06670671e+00, 1.01016245e+00], [-8.75106315e-02, -1.31412088e+00, 3.49492328e-01, -2.78834128e-01, -4.40769426e-01, 9.30706517e-01, 2.91446673e+00, -2.37211212e-02, 1.30748564e+00, -1.17650355e+00, -6.27970398e-02, 6.51956005e-01, -1.85351912e+00, 1.42828754e-01, 1.23561533e+00], [ 4.04778080e-01, 1.70310127e+00, -4.89405048e-01, -8.47971798e-01, -8.92854292e-01, -1.23339252e+00, 6.54552541e-02, -1.57678584e+00, 2.12018396e+00, 2.02141793e+00, -1.12194699e-01, -1.21045605e+00, 1.80425311e-01, -1.94521262e-01, -2.31785822e-02], [-5.30096374e-01, 1.06130520e+00, 1.41223130e+00, -3.01554496e+00, 3.47690128e-01, 1.21995148e+00, -2.01653050e+00, -8.75578920e-02, -1.34846698e-01, 1.09989037e+00, 9.01147297e-01, 5.05278562e-01, -6.11775207e-01, 1.36377261e+00, -1.76435604e+00], [-3.15818245e-03, 1.74375715e-01, 1.43644069e+00, -4.42938092e-01, 6.67447769e-02, 1.25380201e-01, 8.80663060e-02, 1.88376560e+00, -2.70092667e-01, -1.38520705e-02, 1.70191954e+00, -1.33603806e-01, -1.75818743e+00, -9.84197253e-01, 4.91216929e-01], [-2.07162389e-01, -5.10018841e-01, 1.88470078e+00, -7.45827949e-01, -2.08241721e-01, 2.93939057e-01, -1.90247749e+00, 1.81134030e-01, 1.36090122e+00, 1.94098679e+00, 7.32360800e-01, -1.49837424e+00, -2.65326826e-01, -6.87741557e-01, -1.49080927e+00], [ 8.43112821e-01, -1.39942770e+00, -1.58203416e-01, -1.04479318e+00, -1.05378768e+00, -7.49574138e-01, -8.07755102e-01, -1.11375149e+00, -1.02997243e-01, -5.80368540e-02, -1.01868833e-01, 5.27943413e-01, 7.60625998e-02, -7.09779297e-02, -9.03557617e-02]])
'파이썬 > Numpy' 카테고리의 다른 글
[Python] AttributeError: 'NoneType' object has no attribute 'split' (0) | 2023.04.14 |
---|