Pandas加载大数据集

Scaling to large datasets --- pandas 2.1.4 documentationhttps://pandas.pydata.org/docs/user_guide/scale.html#use-efficient-datatypes官方文档提供了4种方法:只加载需要的列、转化数据类型、使用chunking(转化文件存储格式)、使用Dask(使用多进程/线程加载数据)。

python 复制代码
pd_csv.to_parquet(file_path_p) #将文件从原始的csv格式转为parquet格式
data = pd.read_parquet(file_path_p,columns=columns) #加载特定column

data['Timestamp_day'] = data['Timestamp_day'].astype("category") #把数据类型为Object且取值较为有限的列转为Category,以减少内存占用

print(data.dtypes) # 查看各列的数据类型
print(data.memory_usage(deep=True)) #查看各列的空间占用
相关推荐
观察员1 天前
用 Pandas 对抓取的电影数据进行分析
pandas
人工干智能1 天前
科普:pandas 时间偏移别名:ts.resample(“5Min“).sum()
python·pandas
benchmark_cc6 天前
批量获取量化数据时,如何设置合理的超时和重试机制?——QuantDash 高性能实战指南
开发语言·人工智能·python·pandas·量化·quantdash
2601_966949656 天前
使用 Pandas 读取批量数据时如何避免内存溢出?QuantDash 量化数据工程师避坑指南
开发语言·python·pandas·tushare·akshare·quantdash
三十岁老牛再出发7 天前
08.18每日总结
c++·python·numpy·pandas
虎头金猫10 天前
如何在群晖NAS上通过Docker部署CloudSaver?群晖部署CloudSaver教程|聚合资源搜索并实现远程访问
运维·服务器·网络·python·docker·容器·pandas
Uncommon.11 天前
使用pandas处理csv并转为张量
pytorch·python·深度学习·pandas
STR_Liang13 天前
pandas.read_html 报错FileNotFoundError、OSError Traceback (most recent call last)
pandas
㳺三才人子14 天前
初探 Data Analysis - Matplotlib
python·plotly·pandas·matplotlib
quantdash_cc15 天前
告别自建 Requests/BS4 网页爬虫:基于 QuantDash 搭建零维保的高性能量化行情流水线
开发语言·爬虫·python·pandas·量化·quantdash