代码:
from sklearn.ensemble import RandomForestRegressor
rf = RandomForestRegressor(n_estimators= 1000, random_state=42)
rf.fit(train_features, train_labels)
最后一行代码:rf.fit(train_features, train_labels)报错:
TypeError: float() argument must be a string or a number, not 'Timestamp'
请问这个问题怎么解决呢
train_features 和 train_labels 都是什么数据类型呢?错误的原因是这两个参数需要的是 string 或者 number ,你提供的却是 Timestamp 。使用 Python 的 type 函数确认下类型吧。