我有以下数据集:
PID,RUN_START_DATE,PUSHUP_START_DATE,SITUP_START_DATE,PULLUP_START_DATE
1,2013-01-24,2013-01-02,,2013-02-03
2,2013-01-30,2013-01-21,2013-01-13,2013-01-06
3,2013-01-29,2013-01-28,2013-01-01,2013-01-29
4,2013-02-16,2013-02-12,2013-01-04,2013-02-11
5,2013-01-06,2013-02-07,2013-02-25,2013-02-12
6,2013-01-26,2013-01-28,2013-02-12,2013-01-10
7,2013-01-26,,2013-01-12,2013-01-30
8,2013-01-03,2013-01-24,2013-01-19,2013-01-02
9,2013-01-22,2013-01-13,2013-02-03,
10,2013-02-06,2013-01-16,2013-02-07,2013-01-11
我知道我可以numpy.argsort
用来返回值的排序索引:
SQ_AL_INDX = numpy.argsort(df_sequence[['RUN_START_DATE', 'PUSHUP_START_DATE', 'SITUP_START_DATE', 'PULLUP_START_DATE']], axis=1)
...返回...
RUN_START_DATE PUSHUP_START_DATE SITUP_START_DATE PULLUP_START_DATE
0 2 1 0 3
1 3 2 1 0
2 2 1 0 3
3 2 3 1 0
4 0 1 3 2
5 3 0 1 2
6 1 2 0 3
7 3 0 2 1
8 3 1 0 2
9 3 1 0 2
但是,它似乎把pandas.NaT
价值观放在第一位。所以在这个例子where PID == 1
中,排序顺序返回2 1 0 3
。但是,第二个索引位置是一个pandas.Nat
值。
如何在跳过pandas.NaT
值的同时获取已排序的索引(例如,返回索引值将是2 1 np.NaN 3
or2 1 pandas.NaT 3
或更好1 0 2
,PID 1
而不是2 1 0 3
)?