Titanic-Machine-Learning-from-Disaster icon indicating copy to clipboard operation
Titanic-Machine-Learning-from-Disaster copied to clipboard

Issue running In[39]

Open tirthshah7 opened this issue 3 years ago • 2 comments

I was trying this code and I am having an issue running In[39]. I am having a value error. image image Did you have the same problem? if not how to solve this issue?

tirthshah7 avatar Feb 26 '22 23:02 tirthshah7

You need to get rid of the commas, and it will work:

for dataset in train_test_data: dataset.loc[ dataset['Age'] <= 16, 'Age'] = 0 dataset.loc[(dataset['Age'] > 16) & (dataset['Age'] <= 26)] = 1 dataset.loc[(dataset['Age'] > 26) & (dataset['Age'] <= 36), 'Age'] = 2 dataset.loc[(dataset['Age'] > 36) & (dataset['Age'] <= 62), 'Age'] = 3 dataset.loc[ dataset['Age'] > 62, 'Age'] = 4

patross7 avatar Jun 19 '24 20:06 patross7

I was trying this code and I am having an issue running In[39]. I am having a value error. image image Did you have the same problem? if not how to solve this issue?

You need to get rid of the commas, and it will work:

for dataset in train_test_data: dataset.loc[ dataset['Age'] <= 16, 'Age'] = 0 dataset.loc[(dataset['Age'] > 16) & (dataset['Age'] <= 26)] = 1 dataset.loc[(dataset['Age'] > 26) & (dataset['Age'] <= 36), 'Age'] = 2 dataset.loc[(dataset['Age'] > 36) & (dataset['Age'] <= 62), 'Age'] = 3 dataset.loc[ dataset['Age'] > 62, 'Age'] = 4

patross7 avatar Jun 19 '24 20:06 patross7