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: enter image description here

and here's train series:there's no time, date in index.

enter image description here

finally, test: enter image description here

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 timestamps 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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -