Changes the type of the column to target_type and converts the data of this column Example: >>> import pathway as pw >>> t1 = pw.debug.table_from_markdown(''' ... val ... 1 10 ... 2 9 ... 3 8 ... 4 7''') >>> t1.schema <pathway.Schema types={'val
(target_type: Any, col: expr.ColumnExpression | Value)
| 240 | |
| 241 | |
| 242 | def cast(target_type: Any, col: expr.ColumnExpression | Value) -> expr.CastExpression: |
| 243 | """Changes the type of the column to target_type and converts the data of this column |
| 244 | |
| 245 | Example: |
| 246 | |
| 247 | >>> import pathway as pw |
| 248 | >>> t1 = pw.debug.table_from_markdown(''' |
| 249 | ... val |
| 250 | ... 1 10 |
| 251 | ... 2 9 |
| 252 | ... 3 8 |
| 253 | ... 4 7''') |
| 254 | >>> t1.schema |
| 255 | <pathway.Schema types={'val': <class 'int'>}, id_type=<class 'pathway.engine.Pointer'>> |
| 256 | >>> pw.debug.compute_and_print(t1, include_id=False) |
| 257 | val |
| 258 | 7 |
| 259 | 8 |
| 260 | 9 |
| 261 | 10 |
| 262 | >>> t2 = t1.select(val = pw.cast(float, t1.val)) |
| 263 | >>> t2.schema |
| 264 | <pathway.Schema types={'val': <class 'float'>}, id_type=<class 'pathway.engine.Pointer'>> |
| 265 | >>> pw.debug.compute_and_print(t2, include_id=False) |
| 266 | val |
| 267 | 7.0 |
| 268 | 8.0 |
| 269 | 9.0 |
| 270 | 10.0 |
| 271 | """ |
| 272 | return expr.CastExpression(target_type, col) |
| 273 | |
| 274 | |
| 275 | @check_arg_types |
no outgoing calls
no test coverage detected