[Python] NameError: data_encoded' is not defined [closed]

Discussão em 'Python' iniciado por Stack, Outubro 25, 2024.

  1. Stack

    Stack Membro Participativo

    when i analysis the data and make

    data_encoded[numerical_cols] = scaler.fit_transform(data_encoded[numerical_cols])


    it give me

    NameError Traceback (most recent call last)
    Cell In[140], line 1
    ----> 1 data_encoded[numerical_cols] = scaler.fit_transform(data_encoded[numerical_cols])

    NameError: name 'data_encoded' is not defined


    and I also make

    import pandas as pd
    import numpy as np
    import matplotlib.pyplot as plt
    import seaborn as sns
    from sklearn.preprocessing import StandardScaler


    Display the first few rows to check scaling

    # Scale the numerical features (select specific numerical columns if necessary)
    numerical_cols = ['LotFrontage', 'LotArea', 'OverallQual', 'OverallCond', 'SalePrice']
    data_encoded[numerical_cols] = scaler.fit_transform(data_encoded[numerical_cols])

    # Display the first few rows to check scaling
    print(data_encoded[numerical_cols].head())text

    Continue reading...

Compartilhe esta Página