Зміст курсу
Dealing with Dates and Times in Python
Dealing with Dates and Times in Python
Challenge: Negative Trip Duration
Well, in the last chapter you might notice that for the first 10 rows all the trips started before 13 hours (1 p.m.), and ended close to 00 hours. What if it's just AM/PM missing? Let's try to check it.
How can it be checked? Well, in our dataframe we also have trip_duration
column representing the trip duration in seconds. What if we just add this duration to pickup_datetime
and compare it with dropoff_datetime
?
Please note, that you will need to use
timedelta
objects in this task since you want to 'shift' yourdatetime
object for a certain time. To convert column totimedelta
type usepd.to_timedelta()
function with two arguments: column you want to convert, andunit
- dimension used ('S' for seconds, 'm' for minutes, and so on).
Завдання
- Convert
trip_duration
column intotimedelta
type. Do not forget thattrip_duration
measures in seconds. - Create new column
dropoff_calculated
as the result of addingpickup_datetime
andtrip_duration
. - Print first 10 rows for updated dataframe.
Please, do not change column names in square brackets.
Дякуємо за ваш відгук!
Challenge: Negative Trip Duration
Well, in the last chapter you might notice that for the first 10 rows all the trips started before 13 hours (1 p.m.), and ended close to 00 hours. What if it's just AM/PM missing? Let's try to check it.
How can it be checked? Well, in our dataframe we also have trip_duration
column representing the trip duration in seconds. What if we just add this duration to pickup_datetime
and compare it with dropoff_datetime
?
Please note, that you will need to use
timedelta
objects in this task since you want to 'shift' yourdatetime
object for a certain time. To convert column totimedelta
type usepd.to_timedelta()
function with two arguments: column you want to convert, andunit
- dimension used ('S' for seconds, 'm' for minutes, and so on).
Завдання
- Convert
trip_duration
column intotimedelta
type. Do not forget thattrip_duration
measures in seconds. - Create new column
dropoff_calculated
as the result of addingpickup_datetime
andtrip_duration
. - Print first 10 rows for updated dataframe.
Please, do not change column names in square brackets.
Дякуємо за ваш відгук!
Challenge: Negative Trip Duration
Well, in the last chapter you might notice that for the first 10 rows all the trips started before 13 hours (1 p.m.), and ended close to 00 hours. What if it's just AM/PM missing? Let's try to check it.
How can it be checked? Well, in our dataframe we also have trip_duration
column representing the trip duration in seconds. What if we just add this duration to pickup_datetime
and compare it with dropoff_datetime
?
Please note, that you will need to use
timedelta
objects in this task since you want to 'shift' yourdatetime
object for a certain time. To convert column totimedelta
type usepd.to_timedelta()
function with two arguments: column you want to convert, andunit
- dimension used ('S' for seconds, 'm' for minutes, and so on).
Завдання
- Convert
trip_duration
column intotimedelta
type. Do not forget thattrip_duration
measures in seconds. - Create new column
dropoff_calculated
as the result of addingpickup_datetime
andtrip_duration
. - Print first 10 rows for updated dataframe.
Please, do not change column names in square brackets.
Дякуємо за ваш відгук!
Well, in the last chapter you might notice that for the first 10 rows all the trips started before 13 hours (1 p.m.), and ended close to 00 hours. What if it's just AM/PM missing? Let's try to check it.
How can it be checked? Well, in our dataframe we also have trip_duration
column representing the trip duration in seconds. What if we just add this duration to pickup_datetime
and compare it with dropoff_datetime
?
Please note, that you will need to use
timedelta
objects in this task since you want to 'shift' yourdatetime
object for a certain time. To convert column totimedelta
type usepd.to_timedelta()
function with two arguments: column you want to convert, andunit
- dimension used ('S' for seconds, 'm' for minutes, and so on).
Завдання
- Convert
trip_duration
column intotimedelta
type. Do not forget thattrip_duration
measures in seconds. - Create new column
dropoff_calculated
as the result of addingpickup_datetime
andtrip_duration
. - Print first 10 rows for updated dataframe.
Please, do not change column names in square brackets.