pandas 加载minio 文件数据

就是一个简单记录,基于s3 进行文件存储还是比较方便的

环境准备

  • docker-compose.yaml
version: '3'
services:
  minio:
    image: minio/minio
    ports:
      - "9002:9000"
      - "19001:19001"
    environment:
      MINIO_ACCESS_KEY: minio
      MINIO_SECRET_KEY: minio123
    command: server --console-address :19001 --quiet /data
  • requirements.txt
    主要是依赖,方便通过venv 安装
 
pandas
s3fs
fsspec
pyarrow

读取&效果

  • s3app.py
import pandas as pd
parquet_file = 's3://demo/file2.parquet'
storage_conf = {'endpoint_url':'http://localhost:9002',"key":"minio","secret":"minio123"}
result = pd.read_parquet(parquet_file, engine='pyarrow',storage_options=storage_conf)
print(result.head())
  • 效果

说明

pandas 对于s3 的读取依赖了fsspec,同时实际读取需要安装对应的s3 实现

参考资料

https://s3fs.readthedocs.io/en/latest/
https://filesystem-spec.readthedocs.io/en/latest/
https://pandas.pydata.org/docs/reference/api/pandas.read_parquet.html

posted on   荣锋亮  阅读(167)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-10-01 graylog 索引模型
2022-10-01 pg_eventserv push pg 变动事件到websocket 服务
2022-10-01 graylog 的journal message 实现简单说明
2022-10-01 graylog 的journal message 存储简单说明
2022-10-01 graylog 插件模型之PluginModule
2022-10-01 graylog grn介绍
2017-10-01 debezium 数据变更工具使用

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示