Reputation: 29
This is my code:
X_train, X_test, y_train, y_test = train_test_split(sing.ix[:-10], y.ix[:-10].T.corr(), test_size=0.2)
but I get this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-78-32ea47dd4970> in <module>()
1 # Split data into train and test leaving last ten (10) rows for the final evaluation
----> 2 X_train, X_test, y_train, y_test = train_test_split(sing.ix[:-10], y.ix[:-10].T.corr(), test_size=0.2)
AttributeError: 'float' object has no attribute 'ix'
Can someone explain how to fix it ? Thanks so much!
Upvotes: 1
Views: 2775
Reputation: 56
try typing:
print(type(sing)) # This will output object type of variable.
print(type(y))
and verify they're both DataFrame Objects.
Also to find methods pertaining to object types try typing:
# This will print a list of defined methods according to object type.
print(dir(sing))
or
# Displays documentation according to object/class
help(object type) # Ex. pandas.core.frame.DataFrame
Upvotes: 1