回答編集履歴
1
Update
test
CHANGED
@@ -1,18 +1,12 @@
|
|
1
1
|
```python
|
2
2
|
|
3
|
-
idx = (
|
4
|
-
|
5
|
-
df.groupby(['施設', '個人コード'])
|
3
|
+
idx = df.groupby(['施設', '個人コード']).apply(lambda x: x.index[[0, -1]])
|
6
|
-
|
7
|
-
.apply(lambda x: x.index[[0, -1]].values))
|
8
|
-
|
9
|
-
|
10
4
|
|
11
5
|
df[['start', 'end']] = ['', '']
|
12
6
|
|
13
|
-
df.loc[idx.str[0]
|
7
|
+
df.loc[idx.str[0], 'start'] = 'S'
|
14
8
|
|
15
|
-
df.loc[idx.str[1]
|
9
|
+
df.loc[idx.str[1], 'end'] = 'E'
|
16
10
|
|
17
11
|
|
18
12
|
|