python的division函数_Python/Numpy:Division给了我一个意外的弃用警告
我从一个csv读取数据,然后循环,然后我想除以平均值来规范化它,但得到一个警告。代码是:A = genfromtxt("train.txt", delimiter=';', skip_header=1)
lowid = A[:,1].min(axis=0)
highid = A[:,1].max(axis=0)
X = []
Y = []
for i in np.arange(lowid, highid):
I = A[A[:,1] == i][:, [0,2,3]]
meanp = np.mean(I[:,1]);
meanq = np.mean(I[:,2]);
for j in np.arange(I[:,0].min(axis=0)+2, I[:,0].max(axis=0)):
weekday = int(I[j,0]) % 7
# NORMALIZE:
P = I[j,1] / meanp
pP = I[j-1,1] / meanp
ppP = I[j-2,1] / meanp
X.append([weekday, P, pP, ppP])
Y.append(I[j,2])
在火车.txt看起来像这样:
^{pr2}$
警告:weekday = int(I[j,0]) % 7
DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
P = I[j,1] / meanp
DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
pP = I[j-1,1] / meanp
DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
ppP = I[j-2,1] / meanp
DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
Y.append(I[j,2])
DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
有什么问题吗?
谢谢
编辑好吧,我自己也很快就搞定了:
j必须是整数类型。我是这样修好的:for j in range(int(I[:,0].min(axis=0))+2, int(I[:,0].max(axis=0))):
这样的好办法?我是python新手。。。在
python的division函数_Python/Numpy:Division给了我一个意外的弃用警告相关推荐
- python排大小函数_python numpy 一些函数 大小排序和统计
排序大小函数 import numpy as np size = 100 a = np.random.randint(0, 1000, size=size) print(a) # 排序之后的前k个元素 ...
- python中grid函数_Python / NumPy中meshgrid的目的是什么?
实际上文档中已经提到了np.mgrid的目的: np.mgrid 从坐标向量返回坐标矩阵. 在给定一维坐标数组x1,x2,...,xn的情况下,为N-D网格上的N-D标量/矢量场的矢量化评估制作N-D ...
- python中squeeze函数_Python numpy.squeeze()用法及代码示例
当我们要从数组形状中删除一维条目时,将使用numpy.squeeze()函数. 用法: numpy.squeeze(arr, axis=None ) 参数: arr :[数组]输入数组. axis : ...
- python中isin函数_Python numpy.isin函数方法的使用
numpy.isin numpy.isin(element, test_elements, assume_unique=False, invert=False) [source] 计算test ...
- python 中arange函数_Python numpy.arange函数方法的使用
numpy.arange numpy.arange([start, ]stop, [step, ]dtype=None) 返回给定间隔内的均匀间隔的值. 在半开间隔[start,stop)(换句话说, ...
- python的std函数_Python numpy.nanstd函数方法的使用
numpy.nanstd numpy.nanstd(a, axis=None, dtype=None, out=None, ddof=0, keepdims= 忽略NaN时,计算沿指定轴的标准偏差. ...
- python中argmin函数_Python numpy.argmin()用法及代码示例
numpy.argmin(array,axis = None,out = None):返回特定轴上数组min元素的索引. 参数: array:Input array to work on axis : ...
- python中mat函数_Python Numpy中的Matlab cell2mat函数?
从某种意义上说,Python的"cells"比MATLAB-list长得多.python列表是1d单元格(或者更确切地说,大小为1维的单元格)的直接替代品.二维单元格可以表示为嵌套 ...
- python中reshape函数_Python numpy.reshape函数方法的使用
numpy.reshape numpy.reshape(a, newshape, order='C') [source] 在不更改数据的情况下为数组赋予新的shape.参数 :a :array_ ...
最新文章
- java 邮件模板_Spring Boot 优雅地发送邮件
- 《南溪的目标检测学习笔记》——权重初始化
- Amazon S3 API
- JS 获取宽,高(ie未测)
- 时空解析理论的实验检验方法
- win7创建桌面计算机,win7系统添加或删除虚拟桌面的方法介绍
- table-首列冻结
- LeetCode148经典题目记录(链表排序:快排+递归归并+迭代归并)
- 论文笔记:A novel DRM scheme for accommodating expectations of personal use
- 可爱又能干的小精灵—送餐机器人来啦
- 在线TSV转SQL工具
- 维基解密又双叒叕曝光了 CIA 针对 Mac 和 Linux 的 3 个黑客工具
- linux 怎么看节点核数,Linux怎么查看CPU核数?-linux运维
- Mysql建表——报错1005
- Excel导出功能超时解决方案 -- 异步处理
- IOS 应用内打开三方地图app直接导航(高德坐标)
- Scratch少儿编程与游戏:狙击黑蝙蝠
- hypermill后处理构造器安装_ug10后处理安装步骤ug后处理在什么位置ug法兰克后处理下载ug后处理器如何设置ug后处理构造器...
- 「CTSC2017」吉夫特(Gift) (Lucas定理,状压DP)
- Get、Put、Post、Delete 含义与区别