pd.Timestamp(ts_input, offset=None, tz=None, unit=None) Vous pouvez taper «pd.Timestamp» au format aaaammjj, et il séparera la date / heure avec un espace, un trait d'union ou tout autre délimiteur approprié. Le nombre à 6 chiffres est au format jjmmaa.
import pandas as pd
a=pd.Timestamp('2016-2-1')
# [Out]# Timestamp('2016-02-01 00:00:00')
b=pd.Timestamp('20160301')
# [Out]# Timestamp('2016-03-01 00:00:00')
pd.Timestamp('160301')
# [Out]# Timestamp('2001-03-16 00:00:00')
pd.date_range(start=None, end=None, periods=None, freq='D', tz=None, normalize=False, name=None, closed=None, **kwargs) Pd.date_range () qui itère du début à la fin au format Timestamp
pd.date_range('20160201','20160301')
# [Out]# DatetimeIndex(['2016-02-01', '2016-02-02', '2016-02-03', '2016-02-04',
# [Out]# '2016-02-05', '2016-02-06', '2016-02-07', '2016-02-08',
# [Out]# '2016-02-09', '2016-02-10', '2016-02-11', '2016-02-12',
# [Out]# '2016-02-13', '2016-02-14', '2016-02-15', '2016-02-16',
# [Out]# '2016-02-17', '2016-02-18', '2016-02-19', '2016-02-20',
# [Out]# '2016-02-21', '2016-02-22', '2016-02-23', '2016-02-24',
# [Out]# '2016-02-25', '2016-02-26', '2016-02-27', '2016-02-28',
# [Out]# '2016-02-29', '2016-03-01'],
# [Out]# dtype='datetime64[ns]', freq='D')
pd.date_range('2014-11-01 10:00',periods=20,freq='H')
# [Out]# DatetimeIndex(['2014-11-01 10:00:00', '2014-11-01 11:00:00',
# [Out]# '2014-11-01 12:00:00', '2014-11-01 13:00:00',
# [Out]# '2014-11-01 14:00:00', '2014-11-01 15:00:00',
# [Out]# '2014-11-01 16:00:00', '2014-11-01 17:00:00',
# [Out]# '2014-11-01 18:00:00', '2014-11-01 19:00:00',
# [Out]# '2014-11-01 20:00:00', '2014-11-01 21:00:00',
# [Out]# '2014-11-01 22:00:00', '2014-11-01 23:00:00',
# [Out]# '2014-11-02 00:00:00', '2014-11-02 01:00:00',
# [Out]# '2014-11-02 02:00:00', '2014-11-02 03:00:00',
# [Out]# '2014-11-02 04:00:00', '2014-11-02 05:00:00'],
# [Out]# dtype='datetime64[ns]', freq='H')
pd.date_range('2014-11-01 10:00','2014-11-02 10:00',freq='H')
# [Out]# DatetimeIndex(['2014-11-01 10:00:00', '2014-11-01 11:00:00',
# [Out]# '2014-11-01 12:00:00', '2014-11-01 13:00:00',
# [Out]# '2014-11-01 14:00:00', '2014-11-01 15:00:00',
# [Out]# '2014-11-01 16:00:00', '2014-11-01 17:00:00',
# [Out]# '2014-11-01 18:00:00', '2014-11-01 19:00:00',
# [Out]# '2014-11-01 20:00:00', '2014-11-01 21:00:00',
# [Out]# '2014-11-01 22:00:00', '2014-11-01 23:00:00',
# [Out]# '2014-11-02 00:00:00', '2014-11-02 01:00:00',
# [Out]# '2014-11-02 02:00:00', '2014-11-02 03:00:00',
# [Out]# '2014-11-02 04:00:00', '2014-11-02 05:00:00',
# [Out]# '2014-11-02 06:00:00', '2014-11-02 07:00:00',
# [Out]# '2014-11-02 08:00:00', '2014-11-02 09:00:00',
# [Out]# '2014-11-02 10:00:00'],
# [Out]# dtype='datetime64[ns]', freq='H')
d.date_range('2014-11-01 10:00','2014-11-02 10:00',freq='2H')
# [Out]# DatetimeIndex(['2014-11-01 10:00:00', '2014-11-01 12:00:00',
# [Out]# '2014-11-01 14:00:00', '2014-11-01 16:00:00',
# [Out]# '2014-11-01 18:00:00', '2014-11-01 20:00:00',
# [Out]# '2014-11-01 22:00:00', '2014-11-02 00:00:00',
# [Out]# '2014-11-02 02:00:00', '2014-11-02 04:00:00',
# [Out]# '2014-11-02 06:00:00', '2014-11-02 08:00:00',
# [Out]# '2014-11-02 10:00:00'],
# [Out]# dtype='datetime64[ns]', freq='2H')
Recommended Posts