@@ -1192,11 +1192,97 @@ def __lt__(self, other: Value) -> ir.BooleanValue:
1192
1192
return _binop (ops .Less , self , other )
1193
1193
1194
1194
def asc (self , nulls_first : bool = False ) -> ir .Value :
1195
- """Sort an expression ascending."""
1195
+ """Sort an expression ascending.
1196
+
1197
+ Parameters
1198
+ ----------
1199
+ nulls_first
1200
+ Whether to sort `NULL` values first
1201
+
1202
+ Returns
1203
+ -------
1204
+ Value
1205
+ Sorted expression
1206
+
1207
+ See Also
1208
+ --------
1209
+ [`ibis.asc()`](./expression-generic.qmd#ibis.asc)
1210
+
1211
+ Examples
1212
+ --------
1213
+ >>> import ibis
1214
+ >>> ibis.options.interactive = True
1215
+ >>> t = ibis.memtable({"a": [1, 2, 3, None]})
1216
+ >>> t.order_by(t.a.asc())
1217
+ ┏━━━━━━━━━┓
1218
+ ┃ a ┃
1219
+ ┡━━━━━━━━━┩
1220
+ │ float64 │
1221
+ ├─────────┤
1222
+ │ 1.0 │
1223
+ │ 2.0 │
1224
+ │ 3.0 │
1225
+ │ NULL │
1226
+ └─────────┘
1227
+ >>> t.order_by(t.a.asc(nulls_first=True))
1228
+ ┏━━━━━━━━━┓
1229
+ ┃ a ┃
1230
+ ┡━━━━━━━━━┩
1231
+ │ float64 │
1232
+ ├─────────┤
1233
+ │ NULL │
1234
+ │ 1.0 │
1235
+ │ 2.0 │
1236
+ │ 3.0 │
1237
+ └─────────┘
1238
+ """
1196
1239
return ops .SortKey (self , ascending = True , nulls_first = nulls_first ).to_expr ()
1197
1240
1198
1241
def desc (self , nulls_first : bool = False ) -> ir .Value :
1199
- """Sort an expression descending."""
1242
+ """Sort an expression descending.
1243
+
1244
+ Parameters
1245
+ ----------
1246
+ nulls_first
1247
+ Whether to sort `NULL` values first.
1248
+
1249
+ Returns
1250
+ -------
1251
+ Value
1252
+ Sorted expression
1253
+
1254
+ See Also
1255
+ --------
1256
+ [`ibis.desc()`](./expression-generic.qmd#ibis.desc)
1257
+
1258
+ Examples
1259
+ --------
1260
+ >>> import ibis
1261
+ >>> ibis.options.interactive = True
1262
+ >>> t = ibis.memtable({"a": [1, 2, 3, None]})
1263
+ >>> t.order_by(t.a.desc())
1264
+ ┏━━━━━━━━━┓
1265
+ ┃ a ┃
1266
+ ┡━━━━━━━━━┩
1267
+ │ float64 │
1268
+ ├─────────┤
1269
+ │ 3.0 │
1270
+ │ 2.0 │
1271
+ │ 1.0 │
1272
+ │ NULL │
1273
+ └─────────┘
1274
+ >>> t.order_by(t.a.desc(nulls_first=True))
1275
+ ┏━━━━━━━━━┓
1276
+ ┃ a ┃
1277
+ ┡━━━━━━━━━┩
1278
+ │ float64 │
1279
+ ├─────────┤
1280
+ │ NULL │
1281
+ │ 3.0 │
1282
+ │ 2.0 │
1283
+ │ 1.0 │
1284
+ └─────────┘
1285
+ """
1200
1286
return ops .SortKey (self , ascending = False , nulls_first = nulls_first ).to_expr ()
1201
1287
1202
1288
def to_pandas (self , ** kwargs ) -> pd .Series :
0 commit comments