polars.SQLContext.register_many#

SQLContext.register_many(
frames: Mapping[str, CompatibleFrameType | None] | None = None,
**named_frames: CompatibleFrameType | None,
) Self[source]#

使用关联的名称将多个急切/懒加载的帧注册为表格。

Parameters:
frames

一个 {name:frame, ...} 映射。

**named_frames

命名的急切/惰性框架,作为kwargs提供。

示例

>>> lf1 = pl.LazyFrame({"a": [1, 2, 3], "b": ["m", "n", "o"]})
>>> lf2 = pl.LazyFrame({"a": [2, 3, 4], "c": ["p", "q", "r"]})
>>> lf3 = pl.LazyFrame({"a": [3, 4, 5], "b": ["s", "t", "u"]})
>>> lf4 = pl.LazyFrame({"a": [4, 5, 6], "c": ["v", "w", "x"]})

一次性注册多个帧,可以通过传递字典来实现…

>>> ctx = pl.SQLContext().register_many({"tbl1": lf1, "tbl2": lf2})
>>> ctx.tables()
['tbl1', 'tbl2']

…或者使用关键字参数:

>>> ctx.register_many(tbl3=lf3, tbl4=lf4).tables()
['tbl1', 'tbl2', 'tbl3', 'tbl4']