【问题标题】:Sort single column numpy arrays using another numpy array in Python使用 Python 中的另一个 numpy 数组对单列 numpy 数组进行排序
【发布时间】:2013-05-07 09:20:16
【问题描述】:

考虑我使用以下方法从文本文件加载列:

x, y, z = np.loadtxt(myfile, unpack=True)

通过增加x 的值对xyz 进行排序的语法是什么?

【问题讨论】:

    标签: python arrays sorting numpy


    【解决方案1】:

    你想使用numpy.argsort

    argsortx = np.argsort(x)
    x, y, z = x[argsortx], y[argsortx], z[argsortx]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-14
      • 2016-04-30
      • 2013-10-04
      • 1970-01-01
      • 2015-01-10
      • 1970-01-01
      相关资源
      最近更新 更多