In [1]:
import pandas as pd
In [2]:
df = pd.read_csv('data/src/sample_pandas_normal.csv')
s = df['state']
In [3]:
%timeit s.map({'NY': 'NewYork', 'CA': 'California', 'TX': 'Texas'})
In [4]:
%timeit s.replace({'NY': 'NewYork', 'CA': 'California', 'TX': 'Texas'})
In [5]:
s_copy = s.copy()
%timeit s_copy.update(s_copy.map({'NY': 'NewYork'}))
In [6]:
s_copy = s.copy()
%timeit s_copy.replace({'NY': 'NewYork'}, inplace=True)
In [7]:
s_copy = s.copy()
%timeit s_copy.update(s_copy.map({'NY': 'NewYork', 'CA': 'California', 'TX': 'Texas'}))
In [8]:
s_copy = s.copy()
%timeit s_copy.replace({'NY': 'NewYork', 'CA': 'California', 'TX': 'Texas'}, inplace=True)
In [9]:
%timeit s.map({'NY': 'NewYork'})
In [10]:
%timeit s.replace({'NY': 'NewYork'})
In [11]:
df = pd.read_csv('data/src/titanic_train.csv')
s = df['Sex']
In [12]:
%timeit s.map({'male': 0, 'female': 1})
In [13]:
%timeit s.replace({'male': 0, 'female': 1})