Stuck with ColumnTransformer

Im currently working on a regresseion chalenge Project. I tried to Normalize the data using the ColumnTransformer from sklearn:

import app
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

import tensorflow as tf
from tensorflow	import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras import layers

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import Normalizer
from sklearn.metrics import r2_score
from sklearn.compose import ColumnTransformer

dataset = pd.read_csv("admissions_data.csv")
dataset = dataset.drop(["Serial No."], axis = 1)
features = dataset.iloc[:, 0:-1]
labels = dataset.iloc[:, -1]
features = pd.get_dummies(features)
features_train, features_test, labels_train, labels_test = train_test_split(features, labels, test_size=0.33, random_state=42)
print(features_train.describe)
ct = ColumnTransformer([('normalize', Normalizer(), ['GRE Score', 'TOEFL Score', 'University Rating', 'SOP', 'LOR', 'CGPA', 'Research'])], remainder='passthrough')
features_train_scaled = ct.fit_transform(features_train)
features_test_scaled = ct.transform(features_test)

But I allways get this error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py", line 2897, in get_loc
    return self._engine.get_loc(key)
  File "pandas/_libs/index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'LOR'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sklearn/utils/__init__.py", line 447, in _get_column_indices
    col_idx = all_columns.get_loc(col)
  File "/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py", line 2899, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas/_libs/index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'LOR'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "script.py", line 26, in <module>
    features_train_scaled = ct.fit_transform(features_train)
  File "/usr/local/lib/python3.6/dist-packages/sklearn/compose/_column_transformer.py", line 529, in fit_transform
    self._validate_remainder(X)
  File "/usr/local/lib/python3.6/dist-packages/sklearn/compose/_column_transformer.py", line 327, in _validate_remainder
    cols.extend(_get_column_indices(X, columns))
  File "/usr/local/lib/python3.6/dist-packages/sklearn/utils/__init__.py", line 456, in _get_column_indices
    ) from e
ValueError: A given column is not a column of the dataframe

I dont have any Idea why it says that a given column is not a column of the dataframe, couse i double checked everything. There seems to be a problem with the ‘LOR’ collumn I select in the ColumnTransformer, but this column actualy exists in “features” , so I dont have any Idea whats wrong. Please Help :slight_smile:

Do you happen to reference an index at 0 somewhere?
I’m wondering if you’re trying to select a column (a value) that doesn’t exist(?)

I found this, which is why I ask that question.

Also, are all your variables the same type (the ones you’re trying to transform)?
https://machinelearningmastery.com/columntransformer-for-numerical-and-categorical-data/