python del vs pandas drop [英] python del vs pandas drop

查看:75
本文介绍了python del vs pandas drop的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可能是个争论不休的问题,但是出于pandas.droppython del函数的考虑,这在大型数据集上的性能更好吗?

I know it might be old debate, but out of pandas.drop and python del function which is better in terms of performance over large dataset?

我正在使用python 3学习机器学习,并且不确定使用哪个.我的数据为pandas数据帧格式.但是python del函数在python的built-in function中.

I am learning machine learning using python 3 and not sure which one to use. My data is in pandas data frame format. But python del function is in built-in function for python.

推荐答案

在10Mb的股票数据上对其进行了测试,得出以下结果:

tested it on a 10Mb data of stocks, got the following results:

使用以下代码进行丢弃

t=time.time()
d.drop(labels="2")
print(time.time()-t)

0.003617525100708008

0.003617525100708008

对于del在同一列上具有以下代码:

for del with the following code on the same column:

t=time.time()
del d[2]
print(time.time()-t)

我得到的时间是:

0.0045168399810791016

0.0045168399810791016

在不同的数据集和列上重新运行没有显着差异

reruns on different datasets and columns didn't make any significant difference

这篇关于python del vs pandas drop的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆