File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
solution/0100-0199/0197.Rising Temperature Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 86
86
JOIN Weather AS w2
87
87
ON SUBDATE(w1 .recordDate , 1 ) = w2 .recordDate AND w1 .temperature > w2 .temperature ;
88
88
```
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
+ ```
89
102
90
103
<!-- tabs:end -->
Original file line number Diff line number Diff line change 79
79
JOIN Weather AS w2
80
80
ON SUBDATE(w1 .recordDate , 1 ) = w2 .recordDate AND w1 .temperature > w2 .temperature ;
81
81
```
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
+ ```
82
95
83
96
<!-- tabs:end -->
Original file line number Diff line number Diff line change
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" ]]
You can’t perform that action at this time.
0 commit comments