在python中for in循环怎么用_在for循环中使用python numpy linspace(using python numpy linspace in for loop)...

I am trying to use linspace in a for loop. I would like intervals of 0.5 between 0 and 10. It appears the z_bin is executing properly.

My question: How can I use linspace correctly in the for loop in place of the range function that is shown next to it in the comment line? What do I need to change in the loop as I move from working with integers to working with decimals?

z_bin = numpy.linspace (0.0,10.0,num=21)

print 'z_bin: ', z_bin

num = len(z_bin)

grb_binned_data = []

for i in numpy.linspace(len(z_bin)-1): #range(len(z_bin)-1):

zmin = z_bin[i]

zmax = z_bin[i+1]

grb_z_bin_data = []

for grb_row in grb_data:

grb_name = grb_row[0]

ra = grb_row[1]

dec = grb_row[2]

z = float(grb_row[3])

if z > zmin and z <= zmax:

grb_z_bin_data.append(grb_row)

grb_binned_data.append(grb_z_bin_data)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值