python 2.7 - There are two format of Time series datetime in the same series, how to change them to one format? -
i want split time series 2 set: train , test. here's code:
train = data.iloc[:1100] test = data.iloc[1101:]
here's time series looks like:
and here's train series:there's no time, date in index.
how change index same form?
consider simplified series s
s = pd.series(1, pd.date_range('2010-08-16', periods=5, freq='12h')) s 2010-08-16 00:00:00 1 2010-08-16 12:00:00 1 2010-08-17 00:00:00 1 2010-08-17 12:00:00 1 2010-08-18 00:00:00 1 freq: 12h, dtype: int64
but when subset s
leaving timestamp
s need no time element, pandas
me "favor" of not displaying bunch of zeros no reason.
s.iloc[::2] 2010-08-16 1 2010-08-17 1 2010-08-18 1 freq: 24h, dtype: int64
but rest assured, values same:
s.iloc[::2].index[0] == s.index[0] true
and have same dtype , precision
print(s.iloc[::2].index.values.dtype) dtype('<m8[ns]')
and
print(s.index.values.dtype) dtype('<m8[ns]')
Comments
Post a Comment