【发布时间】:2020-12-06 03:09:03
【问题描述】:
我收到一个错误,但不太清楚为什么会这样......这是我的数据看起来像这样的一点
Date/Time Lat Lon Base
0 8/1/2014 0:03:00 40.7366 -73.9906 B02512
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import preprocessing
df = pd.read_csv('aug.csv')
df.head()
X = df.drop(columns =['Base'])
clus = df[['Lat','Lon']]
y = clus
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.3, random_state=1)
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors = 1)
knn.fit(X_train,y_train)
#Here is my error from the knn.fit(X_train,y_train)
ValueError: could not convert string to float: '8/11/2014 7:33:00'
【问题讨论】: