描述
- 我们在做数据分析的时候,经常会读取文件的数据之后转换成
np.ndarray
对象,但是np.ndarray
经常默认以科学计数法显示,比如:
import pandas as pd
import numpy as np
mnist = pd.read_csv('../dataset/all_mnist_data.csv').values
instance = mnist[0]
print(instance)
[ 5.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
... ... ... ...
0.00000000e+00 1.17187500e-02 7.03125000e-02 7.03125000e-02
7.03125000e-02 4.92187500e-01 5.31250000e-01 6.83593750e-01
1.01562500e-01 6.48437500e-01 9.96093750e-01 9.64843750e-01
... ... ... ...
0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
0.00000000e+00]
解决方法
import pandas as pd
import numpy as np
'''只要设置这句代码就可以了'''
np.set_printoptions(suppress=True)
mnist = pd.read_csv('../dataset/all_mnist_data.csv').values
instance = mnist[0]
print(instance)
[ 5. 0. 0. 0. 0. 0. 0.
... ... ... ... ... ... ...
0.01171875 0.0703125 0.0703125 0.0703125 0.4921875 0.53125
0.68359375 0.1015625 0.6484375 0.99609375 0.96484375 0.49609375
... ... ... ... ... ... ...
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. ]