I am trying to speed up the followingThe code to obtain Box&Coxobtains Box and Cox transformed data, where the. The original data is a Pandas Dataframe,DataFrame and the process uses this DataFrame.
I am trying to speed up the following code. If you can elaborate in faster way of doing this it would be very helpulhelpful.
import numpy as np
import pandas as pd
from numpy.random import randn
from scipy import stats
np.random.seed(1)
df = pd.DataFrame(np.random.randint(1, 100,size=(100, 4)))
def st_bc(data):
data_bc = pd.DataFrame()
for column in list(data):
data_bc[column], lam = stats.boxcox(data[column])
return data_bc
st_bc(data = df)
````
import numpy as np
import pandas as pd
from numpy.random import randn
from scipy import stats
np.random.seed(1)
df = pd.DataFrame(np.random.randint(1, 100,size=(100, 4)))
def st_bc(data):
data_bc = pd.DataFrame()
for column in list(data):
data_bc[column], lam = stats.boxcox(data[column])
return data_bc
st_bc(data = df)