赞
踩
返回修改了类型之后的数组
stock_change.astype(np.int32)
构造包含数组中原始数据字节的Python字节
arr = np.array([[[1, 2, 3], [4, 5, 6]], [[12, 3, 34], [5, 6, 7]]])
arr.tostring()
jupyter输出太大可能导致崩溃问题
如果遇到
IOPub data rate exceeded.
The notebook server will temporarily stop sending output
to the client in order to avoid crashing it.
To change this limit, set the config variable
`--NotebookApp.iopub_data_rate_limit`.
这个问题是在jupyer当中对输出的字节数有限制,需要去修改配置文件
创建配置文件
jupyter notebook --generate-config
vi ~/.jupyter/jupyter_notebook_config.py
取消注释,多增加
## (bytes/sec) Maximum rate at which messages can be sent on iopub before they
# are limited.
c.NotebookApp.iopub_data_rate_limit = 10000000
但是不建议这样去修改,jupyter输出太大会崩溃
import numpy as np
# 数组类型转换:.astype()
ar1 = np.arange(10, dtype=float)
print('ar1 = {0}, ar1.dtype = {1}'.format(ar1, ar1.dtype))
print('-' * 100)
# a.astype():转换数组类型
# 注意:养成好习惯,数组类型用np.int32,而不是直接int32
ar2 = ar1.astype(np.int32) # 可以在参数位置设置数组类型
print('ar2 = {0}, ar2.dtype = {1}'.format(ar2, ar2.dtype))
打印结果:
ar1 = [0. 1. 2. 3. 4. 5. 6. 7. 8. 9.], ar1.dtype = float64
----------------------------------------------------------------------------------------------------
ar2 = [0 1 2 3 4 5 6 7 8 9], ar2.dtype = int32
Process finished with exit code 0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。