I am splitting the data into training data and testing data like so:
train, test = train_test_split(dataFrame(), test_size=0.2)
Which works wonders, my training data frame looks like this:
PassengerId Survived SibSp Parch
77 78 0 0 0
748 749 0 1 0
444 445 1 0 0
361 362 0 1 0
576 577 1 0 0
27 28 0 3 2
232 233 0 0 0
424 425 0 1 1
785 786 0 0 0
… … … … …
I am now attempting to get the X and Y columns, X being my SibSp column and Y being my Parch column. After following many tutorials on Regression and training my AI, every person "split" the columns into x and y like so:
x = train[:, 0:2]
However, after many variations and googling, I cannot solve this error this line is giving me nor understand it:
TypeError: unhashable type: 'slice'
How can I split the SibSp column into an array of x and the Parch column into an array of y within my training data frame?
You can also do the following: split(x = df, f = ~ var1 + var2...) This way, you can also achieve the same split dataframe by many variables without using a list in the f parameter.
The correct way to slice is x = train.iloc[:, 0:2]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With