danfo.to_datetime(kwargs) [source]
Parameters | Type | Description | Default |
kwargs | Object | { data: Array | Series, the object to convert. format: The strftime to parse time, eg "%Y-m-d%", "%m-d-Y%", and "%m-d-Y H%M%S%" } | |
Returns:
return DataFrame
let data = new dfd.date_range({"start":'1/1/2018',period:12, freq:'M'})let sf = new dfd.Series(data)let dt = dfd.to_datetime({data:sf})dt.month().print()dt.month_name().print()dt.weekdays().print()dt.day().print()dt.seconds().print()
//Int representation for month╔═══╤══════════════════════╗║ │ 0 ║╟───┼──────────────────────╢║ 0 │ 0 ║╟───┼──────────────────────╢║ 1 │ 1 ║╟───┼──────────────────────╢║ 2 │ 2 ║╟───┼──────────────────────╢║ 3 │ 3 ║╟───┼──────────────────────╢║ 4 │ 4 ║╚═══╧══════════════════════╝//string representation for month╔═══╤══════════════════════╗║ │ 0 ║╟───┼──────────────────────╢║ 0 │ Jan ║╟───┼──────────────────────╢║ 1 │ Feb ║╟───┼──────────────────────╢║ 2 │ Mar ║╟───┼──────────────────────╢║ 3 │ Apr ║╟───┼──────────────────────╢║ 4 │ May ║╚═══╧══════════════════════╝//string representation for day of the week╔═══╤══════════════════════╗║ │ 0 ║╟───┼──────────────────────╢║ 0 │ Mon ║╟───┼──────────────────────╢║ 1 │ Thu ║╟───┼──────────────────────╢║ 2 │ Thu ║╟───┼──────────────────────╢║ 3 │ Sun ║╟───┼──────────────────────╢║ 4 │ Tue ║╚═══╧══════════════════════╝//Int representation for day of the week╔═══╤══════════════════════╗║ │ 0 ║╟───┼──────────────────────╢║ 0 │ 1 ║╟───┼──────────────────────╢║ 1 │ 4 ║╟───┼──────────────────────╢║ 2 │ 4 ║╟───┼──────────────────────╢║ 3 │ 0 ║╟───┼──────────────────────╢║ 4 │ 2 ║╚═══╧══════════════════════╝//Hour of the day╔═══╤══════════════════════╗║ │ 0 ║╟───┼──────────────────────╢║ 0 │ 0 ║╟───┼──────────────────────╢║ 1 │ 0 ║╟───┼──────────────────────╢║ 2 │ 0 ║╟───┼──────────────────────╢║ 3 │ 0 ║╟───┼──────────────────────╢║ 4 │ 0 ║╚═══╧══════════════════════╝
datetime properties of Series or datetime-like columns in DataFrame can be accessed via accessors in the dt name space. See Accessors