Adding time to the mix

Working with Dates and Times in Python

Max Shron

Data Scientist and Author

Dates and Times

Working with Dates and Times in Python

Dates and Times

# Import datetime
from datetime import datetime
Working with Dates and Times in Python

Dates and Times

# Import datetime
from datetime import datetime

dt = datetime(
Working with Dates and Times in Python

Dates and Times

# Import datetime
from datetime import datetime

dt = datetime(2017, 10, 1
Working with Dates and Times in Python

Dates and Times

# Import datetime
from datetime import datetime

dt = datetime(2017, 10, 1, 15
Working with Dates and Times in Python

Dates and Times

# Import datetime
from datetime import datetime

dt = datetime(2017, 10, 1, 15, 23, 
Working with Dates and Times in Python

Dates and Times

# Import datetime
from datetime import datetime

dt = datetime(2017, 10, 1, 15, 23, 25)
Working with Dates and Times in Python

Dates and Times

# Import datetime
from datetime import datetime

dt = datetime(2017, 10, 1, 15, 23, 25, 500000)
Working with Dates and Times in Python

Dates and Times

# Import datetime
from datetime import datetime

dt = datetime(year=2017, month=10, day=1, 
              hour=15, minute=23, second=25, 
              microsecond=500000)
Working with Dates and Times in Python

Replacing parts of a datetime

print(dt)
2017-10-01 15:23:25.500000
dt_hr = dt.replace(minute=0, second=0, microsecond=0)
print(dt_hr)
2017-10-01 15:00:00
Working with Dates and Times in Python

Capital Bikeshare

Working with Dates and Times in Python

Adding time to the mix

Working with Dates and Times in Python

Preparing Video For Download...