使用Laravel/Eloquent
,我想检索下表中每个week_id
的最大值。
+---------+-----------+
| week_id | value |
+---------+-----------+
| 5 | |
| 6 | 1 |
| 6 | |
| 6 | |
| 7 | 3 |
| 7 | 4 |
| 7 | |
+---------+-----------+
使用MySql
我会这样做:
SELECT week_id, max(value) as max_value FROM foo_table GROUP BY week_id
=>
+---------+-----------+
| week_id | max_value |
+---------+-----------+
| 5 | |
| 6 | 1 |
| 7 | 4 |
+---------+-----------+
我怎样才能在Laravel下实现同样的目标?
答案 0 :(得分:2)
试试这个:
for chunk in pd.read_csv(f, sep = ' ', header = None, chunksize = 512):
# process your chunk here