如何修复“ float()参数必须是字符串或数字,而不是'Timestamp'”

时间:2019-07-27 22:15:29

标签: python pandas scikit-learn

我已经完成了一些代码来进行模型选择,但是这个错误我不理解,并且无法解决,请帮忙

float() argument must be a string or a number, not 'Timestamp'

更改功能

df_new = pd.get_dummies(df, columns=['CARRIER_IATA', 'FLIGHT_NUMBER'
                                    ,'AIRCRAFT_REGISTER_CODE','AIRCRAFT_TYPE','AIRCRAFT_SEATS','ORIGIN',
                                     'DESTINATION','TOT_PAX'
                                    ])
names =[col for col in df_new.columns if col not in ['AIRPORT_CODE', 'FLIGHT_CATEGOR_CODE','DATE_SCHEDULED',
                                                     'TIME_SCHEDULED','DATE_ACTUAL', 'TIME_ACTUAL']] 


X = df_new[names]
y = np.where(df['delay']>10, 1, 0)  # classification
y = df['delay']                     # regression

from sklearn import model_selection, metrics, preprocessing


X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.33, random_state=1337)
scaler = preprocessing.MinMaxScaler()
scaler.fit_transform(X_train)           ## the error pops up here

0 个答案:

没有答案