python - 如何转换excel文件的数据值
问题描述
column_list = []
df_column = pd.read_excel(r'data/health-insurance.xlsx', sheet_name='Sheet1').columns
for i in df_column:
column_list.append(i)
converter = {col: str for col in column_list}
df_actual = pd.read_excel('data/health-insurance.xlsx', converters=converter)
df_actual['New York City','Estimate'][0]
我尝试过使用 lambda、astype、to_numeric 函数,但没有成功。
解决方案
根据https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html,DataFrame对象没有“解析”功能。
您可以将每一行读入一个数组,然后将该数组加载到文件对象中。
推荐阅读
- android - 如何修复firebase身份验证中的错误“电子邮件地址格式错误”?
- c - 为什么“+=”在 SSE intrinsic 中给了我意想不到的结果
- python - 尝试在python中进行分组和总结
- sql - 用 JOIN 替换 - SQL
- swift - 应用程序如何记住用户?
- go - 如何在 Golang 中正确使用可变参数 args?
- html - 为什么我的 GET 请求参数没有显示在我的 url 中?
- javascript - 400 Bad Request for POST to API for js app,但不是 asp.net mvc app
- leaflet - 控制键激活时禁用 boxZoom
- javascript - 在字符类中如何解释单词字符?