Ich bin relativ neu in Python Programming. Wenn ich versuche, die Daten für die Hauptkomponentenanalyse zu standardisieren, erhalte ich die folgende Fehlermeldung.Valueerror: invalid wörtliche für Schwimmer(): 2017.03.18 19: 22: 51-07: 00
Python-Version: 2.7.4.
df = pd.read_csv('E:/Downloads/Datasets/PCA_data.csv')
df.head()
number_people date timestamp day_of_week \
0 37 2015-08-14 17:00:11-07:00 61211 4
1 45 2015-08-14 17:20:14-07:00 62414 4
2 40 2015-08-14 17:30:15-07:00 63015 4
3 44 2015-08-14 17:40:16-07:00 63616 4
4 45 2015-08-14 17:50:17-07:00 64217 4
is_weekend is_holiday temperature is_start_of_semester \
0 0 0 71.76 0
1 0 0 71.76 0
2 0 0 71.76 0
3 0 0 71.76 0
4 0 0 71.76 0
is_during_semester month hour
0 0 8 17
1 0 8 17
2 0 8 17
3 0 8 17
4 0 8 17
x = df.iloc[:,1:8] # all rows, all the features and no labels
y = df.iloc[:, 0] # all rows, label only
# Scale the data to be between -1 and 1
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X = scaler.fit_transform(x)
X
X = scaler.fit_transform(x)
Traceback (most recent call last):
File "<ipython-input-28-ce4e52c57a0a>", line 1, in <module>
X = scaler.fit_transform(x)
File "C:\Users\owner\Anaconda2\lib\site-packages\sklearn\base.py", line 494, in fit_transform
return self.fit(X, **fit_params).transform(X)
File "C:\Users\owner\Anaconda2\lib\site-packages\sklearn\preprocessing\data.py", line 560, in fit
return self.partial_fit(X, y)
File "C:\Users\owner\Anaconda2\lib\site-packages\sklearn\preprocessing\data.py", line 583, in partial_fit
estimator=self, dtype=FLOAT_DTYPES)
File "C:\Users\owner\Anaconda2\lib\site-packages\sklearn\utils\validation.py", line 382, in check_array
array = np.array(array, dtype=dtype, order=order, copy=copy)
ValueError: invalid literal for float(): 2017-03-18 19:22:51-07:00
Bitte kann jemand hineinschauen..Vielen Dank im Voraus.
Sie haben dort eine Datumspalte. Was willst du damit machen? –
Danke..ich werde 'Datum' und 'Zeitstempel' Spalten fallen lassen .. –