00092-pandas 杂项-windows10
前言
pandas 是一个非常有用的 Python 第三方库。
操作系统:Windows 10 专业版
参考文档
将 excel 数据转化为 json
项目源码地址:https://github.com/LuYF-Lemon-love/ChatPhaLaw/blob/main/excel2json.ipynb
excel 文件一共两列,第二列是以 问:
和 答:
开头的多个问答数据(也可能没有),第一列是问答数据的上下文。
导入第三方库
1 | import os |
将 excel 数据转化为 json
1 | # 读取 excel 文件 |
1 | # 读取当前目录下的所有 excel 文件 |
1 | print(json_list[0]) |
1 | ['什么是药品标准?', '药品标准是衡量药品安全、有效和质量可控的标尺。'] |
1 | json_data = pd.DataFrame(json_list, columns=['instruction', 'output']) |
1 | json_data.to_json(path_or_buf='data_without_context.json', orient='records', force_ascii=False, indent=4) |
结语
第九十二篇博文写完,开心!!!!
今天,也是充满希望的一天。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LuYF-Lemon-love の Blog!