代码之家  ›  专栏  ›  技术社区  ›  Prateek Narendra

随机化一个数据数组的顺序,该数组以字符串形式表示为一列[重复]

  •  -2
  • Prateek Narendra  · 技术社区  · 6 年前

    data = np.genfromtxt('../Data/bezdekIris.csv',delimiter=',',usecols=[0,1,2,3,4],dtype=None)
    

    ndarray [(5.1, 3.5, 1.4, 0.2, 'Iris-setosa') 
     (4.9, 3. , 1.4, 0.2, 'Iris-setosa')
     (4.7, 3.2, 1.3, 0.2, 'Iris-setosa') 
     (4.6, 3.1, 1.5, 0.2, 'Iris-setosa')
     (5. , 3.6, 1.4, 0.2, 'Iris-setosa')]
    

    1 回复  |  直到 6 年前
        1
  •  0
  •   lightalchemist    6 年前
    import numpy as np
    
    np.random.seed(12345) # For repeatable results
    np.random.shuffle(data)