I have Dataframe df
i choosed some coulmns of it and i want to divide them into xtrain and xtest accoring to a coulmn called Sevrice. So that raws with 1 and o into the xtrain and nan into xtest.
Service
1
0
0
1
Nan
Nan
xtarin = df.loc[df['Service'].notnull(), ['Age','Fare', 'GSize','Deck','Class', 'Profession_title' ]]
EDITED
ytrain = df['Service'].dropna()
Xtest=df.loc[df['Service'].isnull(),['Age','Fare','GSize','Deck','Class','Profession_title']]
import pandas as pd
from sklearn.linear_model import LogisticRegression
logistic = LogisticRegression()
logistic.fit(xtrain, ytrain)
logistic.predict(xtest)
I get this error for logistic.predict(xtest)
X has 220 features per sample; expecting 307
I think you need
isnull
:Another solution is invert
boolean mask
by~
:EDIT: