我想获得数据帧中列的类型以及列的名称,但是polar只能给我类型。
我试过了。dtypes df.dtypes()。我希望得到每一列的名称及其旁边的类型。
可以在DataFrame
和LazyFrame
对象上使用.schema
import polars as pl
from datetime import time
df = pl.DataFrame({
"a": [1, 2, 3],
"b": [True, False, True],
"c": [[{"a": time(12, 1, 1)}], None, None]
})
df.schema
{'a': Int64, 'b': Boolean, 'c': List(Struct([Field('a': Time)]))}