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