使用Python按ID排除数据帧的行

时间:2018-06-14 08:42:18

标签: python pandas numpy

如果我有以下数据框:

   Station   ID   DateTime    Channel   Count
    0   1   2017-10-01 00:00:00 1   212
    1   1   2017-10-01 00:00:00 2   157
    2   1   2017-10-01 00:00:00 3   258
    3   1   2017-10-01 00:00:00 4   158
    4   1   2017-10-01 01:00:00 1   154
    5   1   2017-10-01 01:00:00 2   141
    6   1   2017-10-01 01:00:00 3   213
    7   1   2017-10-01 01:00:00 4   132
    8   1   2017-10-01 02:00:00 1   153
    9   1   2017-10-01 02:00:00 2   135
    10  1   2017-10-01 02:00:00 3   187
    11  1   2017-10-01 02:00:00 4   127
    12  1   2017-10-01 03:00:00 1   199
    13  1   2017-10-01 03:00:00 2   87
    14  1   2017-10-01 03:00:00 3   129
    15  1   2017-10-01 03:00:00 4   92
    16  1   2017-10-01 04:00:00 1   59

我想排除以下各站的行:    2    五    6    8    9    10    13    14, 并获得这样的新数据框架?

Station   ID   DateTime    Channel   Count
    0   1   2017-10-01 00:00:00 1   212
    1   1   2017-10-01 00:00:00 2   157
    3   1   2017-10-01 00:00:00 4   158
    4   1   2017-10-01 01:00:00 1   154
    7   1   2017-10-01 01:00:00 4   132
    11  1   2017-10-01 02:00:00 4   127
    12  1   2017-10-01 03:00:00 1   199
    15  1   2017-10-01 03:00:00 4   92
    16  1   2017-10-01 04:00:00 1   59

0 个答案:

没有答案