誰かがこの質問で私を助けてくれることを願っています.
1 つの列が時系列である df があります。
これらの時系列を、時間に基づいて 4 つの異なる値にグループ化する必要があります。時刻を 07:00 ~ 11:30、11:31 ~ 16:59、17:00 ~ 19:59、最後に 20:00 ~ 24:00 にグループ化したい。各グループに 1、2、3、および 4 という名前を付けることができます。
最後に、その列を df に追加します。
よろしくお願いします!
EDIT再現可能な例を追加します。
c( "07:02:03", "07:32:03", "08:02:03", "08:32:03",
"09:02:03", "09:32:03", "10:02:03", "10:32:03", "11:02:03", "11:32:03",
"12:02:03", "12:32:03", "13:02:03", "13:32:03", "14:02:03", "14:32:03",
"15:02:03", "15:32:03", "16:02:03", "16:32:03", "17:02:03", "17:32:03",
"18:02:03", "18:32:03", "19:02:03", "19:32:03", "20:02:03", "20:32:03",
"21:02:03", "21:32:03", "22:02:03", "22:32:03", "23:02:03", "23:32:03",
"00:02:03", "00:32:03", "01:02:03", "01:32:03", "02:02:03", "02:32:03",
"03:02:03", "03:32:03", "04:02:03", "04:32:03", "05:02:03", "05:32:03",
"06:02:03", "06:32:03", "07:02:03", "07:32:03", "08:02:03", "08:32:03",
"09:02:03", "09:32:03", "10:02:03", "10:32:03", "11:02:03", "11:32:03",
"12:02:03", "12:32:03", "13:02:03", "13:32:03", "14:02:03", "14:32:03",
"15:02:03", "15:32:03", "16:02:03", "16:32:03", "17:02:03", "17:32:03",
"18:02:03", "18:32:03", "19:02:03", "19:32:03", "20:02:03", "20:32:03",
"21:02:03", "21:32:03", "22:02:03", "22:32:03", "23:02:03", "23:32:03",
"00:02:03", "00:32:03", "01:02:03", "01:32:03", "02:02:03", "02:32:03",
"03:02:03", "03:32:03", "04:02:03", "04:32:03", "05:02:03", "05:32:03",
"06:02:03", "06:32:03", "07:02:03", "07:32:03", "08:02:03", "08:32:03",
"09:02:03", "09:32:03", "10:02:03", "10:32:03", "11:02:03", "11:32:03",
"12:02:03", "12:32:03", "13:02:03", "13:32:03", "14:02:03", "14:32:03",
"15:02:03", "15:32:03", "16:02:03", "16:32:03", "17:02:03", "17:32:03",
"18:02:03", "18:32:03", "19:02:03", "19:32:03", "20:02:03", "20:32:03",
"21:02:03", "21:32:03", "22:02:03", "22:32:03", "23:02:03", "23:32:03",
"00:02:03", "00:32:03", "01:02:03", "01:32:03", "02:02:03", "02:32:03",
"03:02:03", "03:32:03", "04:02:03", "04:32:03", "05:02:03", "05:32:03",
"06:02:03", "06:32:03", "07:02:03", "07:32:03", "08:02:03", "08:32:03",
"09:02:03", "09:32:03", "10:02:03", "10:32:03", "11:02:03", "11:32:03",
"12:02:03", "12:32:03", "13:02:03", "13:32:03", "14:02:03", "14:32:03",
"15:02:03", "15:32:03", "16:02:03", "16:32:03", "17:02:03", "17:32:03",
"18:02:03", "18:32:03", "19:02:03", "19:32:03", "20:02:03", "20:32:03",
"21:02:03", "21:32:03", "22:02:03", "22:32:03", "23:02:03", "23:32:03",
"00:02:03")
-Hlynur
EDIT2 : サンプル df を追加しました。
a b c
1 3 09:00
2 5 13:00
3 8 16:00
4 7 21:00
5 9 19:00
6 2 22:00
.....
次に、列 d にグループ (1,2,2,4,3,4) が表示されます