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)) #查看各列的空间占用
相关推荐
laocooon5238578861 天前
对传入的 x , y 两个数组做折线图, x 对应 x 轴, y 对应 y 轴。并保存到 Task1/image1/T2.png
python·numpy·pandas·matplotlib
Maxwell_li12 天前
新冠检测例子学习查准率和召回率
学习·机器学习·数据分析·回归·numpy·pandas
渡我白衣2 天前
Python 与数据科学工具链入门:NumPy、Pandas、Matplotlib 快速上手
人工智能·python·机器学习·自然语言处理·numpy·pandas·matplotlib
IT北辰3 天前
用 Python 自动解析药品规格并计算包装总容量 —— pandas + 正则实战
开发语言·python·pandas
lbb 小魔仙3 天前
Python 读取 Excel 文件:openpyxl 与 pandas 实战对比
python·excel·pandas
Amber_373 天前
数据分析之(MySQL+普通程序) VS (Python的NumPy/Pandas)
python·mysql·数据分析·numpy·pandas
Lucky高4 天前
Pandas库实践3_索引
开发语言·python·pandas
墨上烟雨4 天前
Pandas读写CSV、Excel、JSON文件
pandas
Serendipity_Carl5 天前
京东手机销售数据分析: 从数据清洗到可视化仪表盘
python·数据分析·pandas·pyecharts
一位代码6 天前
pandas | 查看数据特征的常见属性及方法
pandas