Bootstrap

Pandas DataFrame| 按照字典dict替换Pandas DataFrame的值:三种方法性能比较

Setup

需要将Pandas dataframe df中一列的值根据字典d进行替换,将数字1、2、3、4、5换成字符"number 1", “number 2”,以此类推。

import numpy as np
import pandas as pd
import time

# construct test dataset
n = 1000000 # length of testset
d = {
   1:'number 1',2:
;