python del vs pandas drop

后端 未结 4 2225
孤街浪徒
孤街浪徒 2021-02-13 05:45

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?

I am

4条回答
  •  借酒劲吻你
    2021-02-13 05:50

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

    for drop with the following code

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

    0.003617525100708008

    for del with the following code on the same column:

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

    time i got was:

    0.0045168399810791016

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

提交回复
热议问题