How to Normalise a Pandas DataFrame Column?
0

How to Normalise a Pandas DataFrame Column?

This recipe helps you Normalise a Pandas DataFrame Column

In [1]:
## How to Normalise a Pandas DataFrame Column
def Kickstarter_Example_96():
    print()
    print(format('How to Normalise a Pandas DataFrame Column','*^82'))

    import warnings
    warnings.filterwarnings("ignore")

    # load libraries
    import pandas as pd
    from sklearn import preprocessing

    # Create an example dataframe with a column of unnormalized data
    data = {'score': [234,24,14,27,-74,46,73,-18,59,160]}
    df = pd.DataFrame(data)
    print(); print(df)

    # Normalize The Column
    # Create x, where x the 'scores' column's values as floats
    x = df[['score']].values.astype(float)
    print(); print(x)

    # 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_normalized = pd.DataFrame(x_scaled)

    # View the dataframe
    print(); print(df_normalized)

Kickstarter_Example_96()
********************How to Normalise a Pandas DataFrame Column********************

   score
0    234
1     24
2     14
3     27
4    -74
5     46
6     73
7    -18
8     59
9    160

[[234.]
 [ 24.]
 [ 14.]
 [ 27.]
 [-74.]
 [ 46.]
 [ 73.]
 [-18.]
 [ 59.]
 [160.]]

          0
0  1.000000
1  0.318182
2  0.285714
3  0.327922
4  0.000000
5  0.389610
6  0.477273
7  0.181818
8  0.431818
9  0.759740

Relevant Projects

Big Data Project Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.
Big Data Project PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.
Big Data Project Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.
Big Data Project Choosing the right Time Series Forecasting Methods
There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.
Big Data Project Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.
Big Data Project Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.
Big Data Project Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.
Big Data Project Predict Census Income using Deep Learning Models
In this project, we are going to work on Deep Learning using H2O to predict Census income.
Big Data Project Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.
Big Data Project Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.