zoukankan      html  css  js  c++  java
  • np.array转换为list,嵌套的python list转成一个一维的python list

    np.array转换为list

    1
    meitan = shuju.iloc[start:end, 1:2] 2 3 zhengqi = shuju.iloc[start:end,2:3] 4 print(type(list(l))) 5 newmeitan = np.array(meitan) #[[][][]] 6 newzhengqi = np.array(zhengqi)#[[][][]] 7 print("转换前",newzhengqi) 8 newmeitan = newmeitan.reshape(1, len(newmeitan)).tolist() # [[2,1,1]] 9 10 newzhengqi = newzhengqi.reshape(1, len(newzhengqi)).tolist() # [[2,1,1]]
       print("转换后",newzhengqi)
    
    
    显示如下,第一个是转换前,第二个转化后
    1
    转换前 [[ 63.13064957] 2 [ 66.2085495 ] 3 [ 67.42173767] 4 [ 66.29841614] 5 [ 67.2869339 ] 6 [ 65.04029846] 7 [ 67.9384613 ] 8 [ 69.80317688] 9 [ 66.47814941]] 10 转换后 [[63.1306495666504, 66.2085494995117, 67.4217376708984, 66.2984161376953, 67.2869338989258, 65.0402984619141, 67.9384613037109, 69.8031768798828, 66.4781494140625]]
    嵌套的python list转成一个一维的python list
    1
    x = [[2],[23],[3]] 2 y = sum(x,[]) 3 print(y)
    显示如下
    1
    [2, 23, 3]
  • 相关阅读:
    R-FCN、SSD、YOLO2、faster-rcnn和labelImg实验笔记
    yolov3的anchor机制与损失函数详解
    CV资料推荐
    测试用例设计方法总结
    测试需求分析
    bug生命周期
    linux命令一
    linux 命令二
    linux 命令三
    mysql数据库和禅道安装
  • 原文地址:https://www.cnblogs.com/shizhenqiang/p/8192893.html
Copyright © 2011-2022 走看看