Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to Remove IndentationError: expected an indented block: except ValueError: in Google Colab

Given a dataset I was asked to perform 5 machine learning models on the dataset.

Here is my code:

standard_scaler = StandardScaler()
try:
  X_train=standard_scaler.fit_transform(X_train)
  X_test=standard_scaler.fit_transform(X_test)

except ValueError:

I keep getting

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

except ValueError:
                 ^
IndentationError: expected an indented block 

Can someone please help me figure out this issue?

>Solution :

You need a block in ValueError:

standard_scaler = StandardScaler()
try:
  X_train=standard_scaler.fit_transform(X_train)
  X_test=standard_scaler.fit_transform(X_test)
except ValueError:
    pass  #or any other value you need
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading