chevron_left Time Series Cookbook
Adding new column containing the difference between two date columnsCombining columns containing date and timeCombining columns of years, months and daysConverting a column of strings to datetimeConverting dates to stringsConverting datetime column to date and time columnsConverting DatetimeIndex to Series of datetimeConverting index to datetimeConverting UNIX timestamp to datetimeCreating a column of datesCreating a range of datesExtracting month and year from Datetime columnGetting all weekdays between two datesGetting all weekends between two datesGetting day unit from date columnGetting month unit from date columnGetting name of months in date columnGetting week numbers from a date columnGetting day of week of date columnsGetting year unit from date columnModifying datesOffsetting datetimeRemoving time unit from datesSetting date to beginning of monthSorting DataFrame by datesUsing dates as the index of a DataFrame
Converting DatetimeIndex to Series of datetime in Pandas
Time Series Cookbook
schedule Jul 1, 2022Last updated
tocTable of Contentsexpand_more
Consider the following
date_index = pd.to_datetime(["2019/11/25","2020/12/26"])date_indexDatetimeIndex(['2019-11-25', '2020-12-26'], dtype='datetime64[ns]', freq=None)
To convert this
DatetimeIndex into a
Series of type
pd.Series(date_index)0 2019-11-251 2020-12-26dtype: datetime64[ns]
Note that the underlying data is copied, and so modifying this Series will not mutate the original
DatetimeIndex and vice versa.
Join our newsletter for updates on new DS/ML comprehensive guides (spam-free)
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
Enjoy our search
Hit / to insta-search docs and recipes!