Separating timestamp components

A timestamp object is made of several components, namely, year, month, day, hour, minute, and second. For many time series analyses, it is important to segregate these components and keep them as new columns for later usage.

Since we have made the date column our index, it becomes a lot easier. A separate column for each component can be created as follows:

ts['Year']=ts.index.year
ts['Month']=ts.index.month
ts['Day']=ts.index.day
ts['Hour']=ts.index.hour
ts['Minute']=ts.index.minute
ts['Second']=ts.index.second

The following is the output:

Time series components created as separate columns
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.89.173