numpy genfromtxt排除某些行

时间:2018-07-11 18:16:22

标签: python python-3.x numpy

我有一个庞大的数据集,包含许多值。我想排除某些我认为包含不准确信息的行。例如说我有:

     1     150.37265     1.6093940 11986.75879  4343.98486   6345.683      8.535   2458.348      3.069   2554.732      2.205   2011.244      1.855   1665.491      2.055   2229.020     11.092   1159.925     63.576   1238.034     63.029   1513.357     76.582    -99.999    -99.999    -99.999    -99.999    609.524      1.071    430.542      0.779    293.832      0.365    201.463      0.499     88.605      1.054    316.139      2.791    426.547      2.960    659.435      3.337    761.369      2.897    982.764      3.981    915.068      3.799    147.845      2.344    284.971      2.969    413.933      3.471    520.958      3.385    761.208      3.425   1299.578      4.812     27.115      0.127     32.692      0.134   3946.924     11.148      0.000      0.030 27.50304  1.00000  -1.00000  -1.00000        -1    0    0    2       230   1   1
     2     150.40848     1.6075042 11126.90527  4298.73779   2326.038      3.374   1683.321      2.562   2624.063      2.233   2718.523      2.144   2892.133      2.693    140.665     61.195    281.988     20.099    427.518     22.779    735.361     37.903    -99.999    -99.999    -99.999    -99.999    -99.999    -99.999    -99.999    -99.999    -99.999    -99.999    -99.999    -99.999    480.256      2.452   1503.665      6.085   1532.825      5.610   1883.756      5.638   2196.444      4.918    -99.999    -99.999   2087.671      5.736    892.003      5.755   1354.323      6.468   1339.161      6.241   1990.614      6.614   1823.208      5.300    -99.999    -99.999      0.522      0.225     16.993      0.240    -99.900    -99.900      0.000      0.750 12.51440  1.00000  -1.00000  -1.00000        -1    1    0   11       295   1   0
     3     150.40550     1.6069111 11198.41992  4284.49414    223.931      3.299    111.582      0.887     94.436      0.678     67.895      0.511     61.085      0.507     64.002      6.935     55.312      8.437     65.572      4.568     88.131      5.368     46.054      0.342     36.760      0.223     20.608      0.206     11.796      0.140      8.360      0.086      6.925      0.100      4.889      0.251      8.405      0.461     10.009      0.460     22.655      0.625     28.231      0.567     34.231      0.754     37.358      0.781      6.587      0.501      7.931      0.507      9.492      0.535     15.271      0.591     30.671      0.695     38.314      0.841      1.864      0.125      4.507      0.130    142.376      9.231      0.000      0.030 17.73935  1.00000  -1.00000  -1.00000        -1    0    0    0       314   1   1
     4     150.39050     1.6043303 11558.18359  4222.49707     33.437      1.502     23.667      0.681     16.188      0.566     11.345      0.410      8.666      0.358      6.252      7.394     16.608      6.876     12.765      1.795     25.299      2.120      6.197      0.216      4.550      0.115      1.558      0.082      0.789      0.064      0.392      0.062      0.305      0.044      0.183      0.065      0.463      0.131      0.906      0.157      1.353      0.177      2.328      0.190      3.503      0.273      4.320      0.300      0.098      0.099      0.257      0.142      0.455      0.152      0.721      0.172      3.101      0.241      5.155      0.342      0.047      0.304     -0.538      0.245     21.609      8.478      0.000      0.750 11.57455  1.00248  -1.00000  -1.00000        -1    0    0    0       322   1   1

作为我的数据集的样本,我说第2行和第3行不够准确,我将如何仅导入第1行和第4行。我希望有更多的一般技巧,而不是使用注释2,3因为数据集非常庞大

编辑:不必使用genfromtxt完成该操作,如果还有另一种方法与genfromtxt相同,但是可以跳过列和行,那就太好了!

0 个答案:

没有答案