Write a Pandas program to convert a series of date strings to a timeseries
- برمجة بايثون
- 2021-09-10
- mhanasmh00489829403
الأجوبة
import pandas as pd
date_series = pd.Series(['01 Jan 2015', '10-02-2016', '20180307', '2014/05/06', '2016-04-12', '2019-04-06T11:20'])
print("Original Series:")
print(date_series)
print("\nSeries of date strings to a timeseries:")
print(pd.to_datetime(date_series))
Sample Output:
Original Series: 0 01 Jan 2015 1 10-02-2016 2 20180307 3 2014/05/06 4 2016-04-12 5 2019-04-06T11:20 dtype: object Series of date strings to a timeseries: 0 2015-01-01 00:00:00 1 2016-10-02 00:00:00 2 2018-03-07 00:00:00 3 2014-05-06 00:00:00 4 2016-04-12 00:00:00 5 2019-04-06 11:20:00 dtype: datetime64[ns]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال