Topic Overview and Actualization

Greetings, Space Voyager! Today, we're exploring the concept of "Data Normalization." This technique aims to render numerical data comparable by scaling it down. In this lesson, you will gain insight into the data normalization process and learn how to implement it with Python.

Understanding Data Normalization

Data normalization is a process that brings your data into a common format, allowing for fair and unbiased comparisons. If data sets are in various scales or units, certain data elements may unfairly dominate the analysis. By adjusting these differences, data normalization ensures that all data pieces stand on an equal footing for comparative evaluation, no matter their original scale or unit. This prevents favor towards specific data as a result of their scale or units, promoting accuracy and fairness in data analysis.

Common Data Normalization Techniques
Data Normalization Using Python

Now, let's put theory into practice. Consider the Height dataset of some Space Explorers:

Python
import pandas as pd
df = pd.DataFrame({
    "Space Explorer": ['Spock', 'Kirk', 'McCoy', 'Scotty'],
    "Height": [183, 178, 170, 178]
})

To normalize using Min-Max in Python, the corresponding code is:

df['Height'] = (df['Height'] - df['Height'].min()) / (df['Height'].max() - df['Height'].min())
# After normalization, df['Height'] is [1, 0.61, 0, 0.61]

For Z-Score:

df['Height'] = (df['Height'] - df['Height'].mean()) / df['Height'].std()
# After normalization, df['Height'] is [1.07, 0.14, -1.35, 0.14]
Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal