Polars中导入excel文件

Polars中导入excel文件

1 、直接导入

def pddaoru_sheetname(filedir):

#df1 = pd.read_excel(filedir,sheet_name=name) # polars导入excel文件命令
df = pl.read_excel(filedir) # polars导入excel文件命令
pf = df.to_pandas() # polars导入excel文件命令
#pf = df1.iloc4: # polars导入excel文件命令
kkk=pf.copy()
print(f'导入{filedir}文件, 源有{len(df)}行,有效数据{len(pf)}行')
return kkk

2 、导入多个sheet

ledger = pl.read_excel(pth_ledger, sheet_name='详表', '限速门限修改为321')
ledger_cells = ledger'详表''ECI'.to_list()
ledger_cells_321 = ledger'限速门限修改为321''ECI'.to_list()

3 、指定导入个别列字段类型

liuliang_schema = {'SPID用户数':pl.Int64,'SPID用户占比':pl.Float64}
liuliang = pl.read_excel(pth_liuliang, sheet_name='Sheet1',schema_overrides=liuliang_schema)

4 、复杂导入

schema = {'地市': pl.String, 'enodebid': pl.Int64, '基站名称': pl.String, 'ECI': pl.Int64, '小区名称': pl.String,
'承建商': pl.String, '厂家': pl.String}

d = pl.read_excel(p, sheet_name='Sheet1', raise_if_empty=False, columns=list(schema.keys()),
schema_overrides=schema)

相关推荐
nothing&nowhere7 小时前
用 Python 做问卷数据清洗:无效样本检测与处理实战
开发语言·python·数据清洗·数据处理·问卷星·问卷星脚本·刷问卷
花酒锄作田7 小时前
如何发布自己的 Python 库到 PyPI
python
researcher-Jiang8 小时前
Design Patterns——Template Method入门到情景实战
python·设计模式·模板方法模式
飞猪~11 小时前
LangChain python 版本 第一集
开发语言·python·langchain
2601_9563198812 小时前
最新AI量化提效,先做可验证的小流程
人工智能·python
开飞机的舒克_13 小时前
FastAPI 实战入门:从路由、参数校验到依赖注入的后端开发指南
python·fastapi
霸道流氓气质14 小时前
Kiro 中反编译 JAR 包并分析字节码的流程指南
chrome·python·jar
人工智能时代 准备好了吗14 小时前
AI回答内容进入率监测:引用识别、文本匹配与语义判断
开发语言·人工智能·python
Metaphor69215 小时前
使用 Python 冻结 Excel 文件中的行、列和单元格
开发语言·python·excel