|
255 | 255 | "execution_count": null,
|
256 | 256 | "metadata": {},
|
257 | 257 | "outputs": [
|
258 |
| - { |
259 |
| - "name": "stderr", |
260 |
| - "output_type": "stream", |
261 |
| - "text": [ |
262 |
| - "/Users/jhoward/miniforge3/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", |
263 |
| - " from .autonotebook import tqdm as notebook_tqdm\n" |
264 |
| - ] |
265 |
| - }, |
266 | 258 | {
|
267 | 259 | "data": {
|
268 | 260 | "text/markdown": [
|
|
620 | 612 | " def unique(self, sort=False, bidir=False, start=None): return L(uniqueify(self, sort=sort, bidir=bidir, start=start))\n",
|
621 | 613 | " def val2idx(self): return val2idx(self)\n",
|
622 | 614 | " def cycle(self): return cycle(self)\n",
|
623 |
| - " def groupby(self, key, val=noop): return L(groupby(self, key, val=val))\n", |
| 615 | + " def groupby(self, key, val=noop): return groupby(self, key, val=val)\n", |
624 | 616 | " def map_dict(self, f=noop, *args, **kwargs): return {k:f(k, *args,**kwargs) for k in self}\n",
|
625 | 617 | " def map_first(self, f=noop, g=noop, *args, **kwargs):\n",
|
626 | 618 | " return first(self.map(f, *args, **kwargs), g)\n",
|
|
677 | 669 | " cycle=\"Same as `itertools.cycle`\",\n",
|
678 | 670 | " enumerate=\"Same as `enumerate`\",\n",
|
679 | 671 | " renumerate=\"Same as `renumerate`\",\n",
|
680 |
| - " groupby=\"Same as `groupby`\",\n", |
| 672 | + " groupby=\"Same as `fastcore.basics.groupby`\",\n", |
681 | 673 | " zip=\"Create new `L` with `zip(*items)`\",\n",
|
682 | 674 | " zipwith=\"Create new `L` with `self` zip with each of `*rest`\",\n",
|
683 | 675 | " map_zip=\"Combine `zip` and `starmap`\",\n",
|
|
1219 | 1211 | "test_eq(L(1,2,3).val2idx(), {3:2,1:0,2:1})"
|
1220 | 1212 | ]
|
1221 | 1213 | },
|
| 1214 | + { |
| 1215 | + "cell_type": "code", |
| 1216 | + "execution_count": null, |
| 1217 | + "metadata": {}, |
| 1218 | + "outputs": [ |
| 1219 | + { |
| 1220 | + "data": { |
| 1221 | + "text/markdown": [ |
| 1222 | + "---\n", |
| 1223 | + "\n", |
| 1224 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/foundation.py#L176){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1225 | + "\n", |
| 1226 | + "### L.groupby\n", |
| 1227 | + "\n", |
| 1228 | + "> L.groupby (key, val=<function noop>)\n", |
| 1229 | + "\n", |
| 1230 | + "*Same as `groupby`*" |
| 1231 | + ], |
| 1232 | + "text/plain": [ |
| 1233 | + "---\n", |
| 1234 | + "\n", |
| 1235 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/foundation.py#L176){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1236 | + "\n", |
| 1237 | + "### L.groupby\n", |
| 1238 | + "\n", |
| 1239 | + "> L.groupby (key, val=<function noop>)\n", |
| 1240 | + "\n", |
| 1241 | + "*Same as `groupby`*" |
| 1242 | + ] |
| 1243 | + }, |
| 1244 | + "execution_count": null, |
| 1245 | + "metadata": {}, |
| 1246 | + "output_type": "execute_result" |
| 1247 | + } |
| 1248 | + ], |
| 1249 | + "source": [ |
| 1250 | + "show_doc(L.groupby)" |
| 1251 | + ] |
| 1252 | + }, |
| 1253 | + { |
| 1254 | + "cell_type": "code", |
| 1255 | + "execution_count": null, |
| 1256 | + "metadata": {}, |
| 1257 | + "outputs": [], |
| 1258 | + "source": [ |
| 1259 | + "words = L.split('aaa abc bba')\n", |
| 1260 | + "test_eq(words.groupby(0, (1,2)), {'a':[('a','a'),('b','c')], 'b':[('b','a')]})" |
| 1261 | + ] |
| 1262 | + }, |
1222 | 1263 | {
|
1223 | 1264 | "cell_type": "code",
|
1224 | 1265 | "execution_count": null,
|
|
0 commit comments