回答編集履歴
4
Update
test
CHANGED
@@ -16,12 +16,8 @@
|
|
16
16
|
|
17
17
|
#
|
18
18
|
dfx = (
|
19
|
-
df.groupby('名前')
|
19
|
+
df.groupby('名前', sort=False)
|
20
|
-
.apply(lambda x:
|
21
|
-
|
20
|
+
.apply(lambda x: x.assign(価格=x['価格'].min())))
|
22
|
-
.cummin()
|
23
|
-
.sort_index().reset_index())
|
24
|
-
.reset_index(drop=True))
|
25
21
|
|
26
22
|
print(dfx.to_markdown(index=False))
|
27
23
|
```
|
3
Update
test
CHANGED
@@ -20,16 +20,17 @@
|
|
20
20
|
.apply(lambda x:
|
21
21
|
x.set_index('日付').sort_values('価格')
|
22
22
|
.cummin()
|
23
|
-
.r
|
23
|
+
.sort_index().reset_index())
|
24
24
|
.reset_index(drop=True))
|
25
25
|
|
26
|
-
print(dfx)
|
26
|
+
print(dfx.to_markdown(index=False))
|
27
|
+
```
|
27
28
|
|
28
|
-
#
|
29
|
-
|
29
|
+
| 日付 | 名前 | 価格 |
|
30
|
+
|:------:|:-------|-------:|
|
30
|
-
|
31
|
+
| 4/1 | A | 200 |
|
31
|
-
|
32
|
+
| 4/1 | A | 200 |
|
32
|
-
|
33
|
+
| 4/2 | B | 100 |
|
33
|
-
|
34
|
+
| 4/3 | B | 100 |
|
34
|
-
|
35
|
+
| 4/3 | B | 100 |
|
35
|
-
|
36
|
+
|
2
Update
test
CHANGED
@@ -18,10 +18,10 @@
|
|
18
18
|
dfx = (
|
19
19
|
df.groupby('名前')
|
20
20
|
.apply(lambda x:
|
21
|
-
x.sort_values(
|
21
|
+
x.set_index('日付').sort_values('価格')
|
22
22
|
.cummin()
|
23
|
-
.sort_values(
|
23
|
+
.reset_index().sort_values('日付'))
|
24
|
-
|
24
|
+
.reset_index(drop=True))
|
25
25
|
|
26
26
|
print(dfx)
|
27
27
|
|
@@ -30,6 +30,6 @@
|
|
30
30
|
0 4/1 A 200
|
31
31
|
1 4/1 A 200
|
32
32
|
2 4/2 B 100
|
33
|
-
3 4/
|
33
|
+
3 4/3 B 100
|
34
34
|
4 4/3 B 100
|
35
35
|
```
|
1
Update
test
CHANGED
@@ -17,7 +17,10 @@
|
|
17
17
|
#
|
18
18
|
dfx = (
|
19
19
|
df.groupby('名前')
|
20
|
+
.apply(lambda x:
|
20
|
-
|
21
|
+
x.sort_values(['価格'])
|
22
|
+
.cummin()
|
23
|
+
.sort_values(['日付']))
|
21
24
|
.reset_index(drop=True))
|
22
25
|
|
23
26
|
print(dfx)
|
@@ -26,7 +29,7 @@
|
|
26
29
|
日付 名前 価格
|
27
30
|
0 4/1 A 200
|
28
31
|
1 4/1 A 200
|
29
|
-
2 4/
|
32
|
+
2 4/2 B 100
|
30
33
|
3 4/2 B 100
|
31
|
-
4 4/
|
34
|
+
4 4/3 B 100
|
32
35
|
```
|