英文:
How to Remove IndentationError: expected an indented block: except ValueError: in Google Colab
问题
在给定的数据集上,我被要求对数据集执行 5 个机器学习模型。
以下是我的代码:
standard_scaler = StandardScaler()
try:
X_train=standard_scaler.fit_transform(X_train)
X_test=standard_scaler.fit_transform(X_test)
except ValueError:
但是我一直在得到以下错误:
except ValueError:
^
IndentationError: expected an indented block
有人能帮助我解决这个问题吗?
英文:
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
except ValueError:
^
IndentationError: expected an indented block
Can someone please help me figure out this issue?
答案1
得分: 0
你需要在 ValueError 中添加一个代码块:
standard_scaler = StandardScaler()
try:
X_train = standard_scaler.fit_transform(X_train)
X_test = standard_scaler.fit_transform(X_test)
except ValueError:
pass # 或者其他你需要的值
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论