Skip to content

Instantly share code, notes, and snippets.

@letthedataconfess
Created December 16, 2021 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save letthedataconfess/056d3f12e4a24a43fd455af33b1fb347 to your computer and use it in GitHub Desktop.
Save letthedataconfess/056d3f12e4a24a43fd455af33b1fb347 to your computer and use it in GitHub Desktop.
from sklearn import preprocessing
# Create x, where x the 'Fare' column's values as floats
x = df[['Fare']].values.astype(float)
# Create a minimum and maximum processor object
min_max_scaler = preprocessing.MinMaxScaler()
# Create an object to transform the data to fit minmax processor
x_scaled = min_max_scaler.fit_transform(x)
# Run the normalizer on the dataframe
df['Fare'] = pd.DataFrame(x_scaled)
df.Fare.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment