Skip to content

Commit ff05136

Browse files
committed
Solution for 197.
1 parent 0795486 commit ff05136

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

solution/0100-0199/0197.Rising Temperature/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,18 @@ FROM
8686
JOIN Weather AS w2
8787
ON SUBDATE(w1.recordDate, 1) = w2.recordDate AND w1.temperature > w2.temperature;
8888
```
89+
### **Pandas**
90+
91+
```python
92+
import pandas as pd
93+
94+
95+
def rising_temperature(weather: pd.DataFrame) -> pd.DataFrame:
96+
weather.sort_values(by="recordDate", inplace=True)
97+
return weather[
98+
(weather.temperature.diff() > 0) & (weather.recordDate.diff().dt.days == 1)
99+
][["id"]]
100+
101+
```
89102

90103
<!-- tabs:end -->

solution/0100-0199/0197.Rising Temperature/README_EN.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,18 @@ FROM
7979
JOIN Weather AS w2
8080
ON SUBDATE(w1.recordDate, 1) = w2.recordDate AND w1.temperature > w2.temperature;
8181
```
82+
### **Pandas**
83+
84+
```python
85+
import pandas as pd
86+
87+
88+
def rising_temperature(weather: pd.DataFrame) -> pd.DataFrame:
89+
weather.sort_values(by="recordDate", inplace=True)
90+
return weather[
91+
(weather.temperature.diff() > 0) & (weather.recordDate.diff().dt.days == 1)
92+
][["id"]]
93+
94+
```
8295

8396
<!-- tabs:end -->
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pandas as pd
2+
3+
4+
def rising_temperature(weather: pd.DataFrame) -> pd.DataFrame:
5+
weather.sort_values(by="recordDate", inplace=True)
6+
return weather[
7+
(weather.temperature.diff() > 0) & (weather.recordDate.diff().dt.days == 1)
8+
][["id"]]

0 commit comments

Comments
 (0)