<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 To understand how Pandas works with time series, we need to understand the datetime module of Python. The main object types of this module are below
date - stores year, month, day using Gregorian calendar
time - stores hours, minutes, seconds, microseconds
datetime - both date and time
timedelta - difference between two datetime values - represented as days, seconds, microseconds
datetime module
Step1:  Time delta
You can get the time difference between two dates as timedelta objects
Step2:  Shifting time with timedelta
Step3:  Working with time stamps
Step4:  Printing time stamps
Step5:  The table below gives most popular format strings to use with strftime.
%Y - 4 digit year
%y - 2 digit year
%m - 2 digit month [02,10]
%d - 2 digit day [01,22]
%H - hours in 24 hour clock, 2 digits
%I - hours in 12 hour clock, 2 digits
%M - minutes, 2 digits
%S - seconds, 2 digits
%w - weekday as integer [0 (sun) - 6 (sat)]
%U - week number, 2 digits, from 00-53. First Sunday of the year is the start of the week (1) and days before belong to week 0
%W - week number where Monday is the start of the week
%z - UTC time zone offset as +HHMM or -HHMM, empty is time zone is unknown (naive)
%F - shortcut for %Y-%m-%d (2020-03-12)
%D - shortcut for %m/%d/%y (03/12/20)
If you notice, year, month, date are lower while hour, min, sec are upper cases.
Step6:  Reading timestamps into datetime objects using strptime()
Step7:  Parsing with dateutil package
dateutil is a 3rd party package and allows you to parse common date formats without explicitly stating the format.
<ASSISTANT_TASK:>
Python Code:
from datetime import datetime
now = datetime.now()
now
(now.year, now.month, now.day, now.hour, now.minute)
Explanation: To understand how Pandas works with time series, we need to understand the datetime module of Python. The main object types of this module are below
date - stores year, month, day using Gregorian calendar
time - stores hours, minutes, seconds, microseconds
datetime - both date and time
timedelta - difference between two datetime values - represented as days, seconds, microseconds
datetime module
End of explanation
delta = datetime(2020,3,12) - datetime(2020,9,25)
delta
(delta.days, delta.seconds)
Explanation: Time delta
You can get the time difference between two dates as timedelta objects
End of explanation
from datetime import timedelta
datetime.now() + timedelta(days=25)
datetime.now() - timedelta(days=20, hours=5)
Explanation: Shifting time with timedelta
End of explanation
stamp = datetime.now()
str(stamp)
Explanation: Working with time stamps
End of explanation
stamp.strftime('%Y-%m-%d-%H-%M-%S')
Explanation: Printing time stamps
End of explanation
datetime.now().strftime('Current hour is %I and week number is %U')
datetime.now().strftime('%z')
datetime.now().strftime('%D')
Explanation: The table below gives most popular format strings to use with strftime.
%Y - 4 digit year
%y - 2 digit year
%m - 2 digit month [02,10]
%d - 2 digit day [01,22]
%H - hours in 24 hour clock, 2 digits
%I - hours in 12 hour clock, 2 digits
%M - minutes, 2 digits
%S - seconds, 2 digits
%w - weekday as integer [0 (sun) - 6 (sat)]
%U - week number, 2 digits, from 00-53. First Sunday of the year is the start of the week (1) and days before belong to week 0
%W - week number where Monday is the start of the week
%z - UTC time zone offset as +HHMM or -HHMM, empty is time zone is unknown (naive)
%F - shortcut for %Y-%m-%d (2020-03-12)
%D - shortcut for %m/%d/%y (03/12/20)
If you notice, year, month, date are lower while hour, min, sec are upper cases.
End of explanation
stamp_str = '03/12/20'
datetime.strptime(stamp_str, '%m/%d/%y')
Explanation: Reading timestamps into datetime objects using strptime()
End of explanation
from dateutil.parser import parse
parse('03/12/20')
Explanation: Parsing with dateutil package
dateutil is a 3rd party package and allows you to parse common date formats without explicitly stating the format.
End of explanation
<END_TASK>