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)

相关推荐
程序员龙叔5 小时前
编写高质量 Skill 系列 -- 如何设计需求分析与用例生成的 SKILL
自动化测试·软件测试·python·软件测试工程师·接口测试·性能测试·skill·ai测试
用户8356290780518 小时前
使用 Python 操作 Word 内容控件
后端·python
码云骑士10 小时前
32-慢查询排查全流程(下)-索引优化实战与最左前缀原则
python
闵孚龙10 小时前
《PyTorch 深度修炼》Dataset 和 DataLoader:数据如何喂给模型
人工智能·pytorch·python
goldenrolan10 小时前
A公司物料替代测试系统 v1.7:从需求到 exe/apk 的 AI 辅助全链路实践
android·自动化测试·软件测试·python·ai
菜板春10 小时前
jupyter入门-手册-特征探索
python·jupyter
Metaphor69211 小时前
使用 Python 将 PDF 转换为 HTML
python·pdf·html
极光代码工作室11 小时前
基于数据仓库的电商数据分析平台
大数据·hadoop·python·spark·数据可视化
开发小能手-roy11 小时前
StringBuilder vs StringBuffer:2024年还需要线程安全字符串吗?
开发语言·python·安全