I want to normalize my ambient temperature column (Ta).
Here is my code:
df['Ta'] = df['Ta'].apply(lambda v: (v - df['Ta'].min())) / (df['Ta'].max() - df['Ta'].min())
It works well. But, it is very slow. The file size is 20 MB with the shape of (300000, 8).
Is there any other faster solution to this?
df['Ta'].min()anddf['Ta'].max()in variables, instead of recomputation every time the lambda is called?df['Ta'] = (df['Ta'] - df['Ta'].min()) / (df['Ta'].max() - df['Ta'].min())