polars.disable_string_cache#
- polars.disable_string_cache() bool[source]#
禁用并清除全局字符串缓存。
另请参阅
enable_string_cache启用字符串缓存的函数。
StringCache用于启用和禁用字符串缓存的上下文管理器。
注释
考虑使用
StringCache上下文管理器,以获得更可靠的启用和禁用字符串缓存的方式。当与
StringCache上下文管理器一起使用时,字符串缓存将不会禁用,直到上下文管理器退出。示例
使用相同的全局字符串缓存构造两个Series。
>>> pl.enable_string_cache() >>> s1 = pl.Series("color", ["red", "green", "red"], dtype=pl.Categorical) >>> s2 = pl.Series("color", ["blue", "red", "green"], dtype=pl.Categorical) >>> pl.disable_string_cache()
由于两个Series都是在相同的全局字符串缓存下构建的,它们可以被连接起来。
>>> pl.concat([s1, s2]) shape: (6,) Series: 'color' [cat] [ "red" "green" "red" "blue" "red" "green" ]