Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Fixing the Issues | Working with Dates and Times in pandas
Dealing with Dates and Times in Python
course content

Contenido del Curso

Dealing with Dates and Times in Python

Dealing with Dates and Times in Python

1. Working with Dates
2. Working with Times
3. Timezones and Daylight Savings Time (DST)
4. Working with Dates and Times in pandas

Challenge: Fixing the Issues

Well, in the last chapter you saw, that there were only two rides with negative durations where minutes in both columns were different. But if paid your attention to seconds, you might notice, that that were the minute ending and starting (59 seconds, and 00 respectively). It means that all the inconsistencies can be interpreted as misuages of 12 and 24-hour formats.

Since we have investigated the real reason for the issue, we can now fix it! Let me remind you of one of the ways to replace values in dataframe based on some condition - .where function.

1
df['col_name'].where(~(condition), inplace = True, other = values_to_replace)
copy

Using the following approach all the values in col_name will be replaced with values_to_replace if (condition) is True.

Tarea

  1. For all the trips with negative duration add 12 hours to dropoff_datetime column.
  2. Calculate column duration again.
  3. Print first 5 rows of updated df.

Tarea

  1. For all the trips with negative duration add 12 hours to dropoff_datetime column.
  2. Calculate column duration again.
  3. Print first 5 rows of updated df.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 4. Capítulo 7
toggle bottom row

Challenge: Fixing the Issues

Well, in the last chapter you saw, that there were only two rides with negative durations where minutes in both columns were different. But if paid your attention to seconds, you might notice, that that were the minute ending and starting (59 seconds, and 00 respectively). It means that all the inconsistencies can be interpreted as misuages of 12 and 24-hour formats.

Since we have investigated the real reason for the issue, we can now fix it! Let me remind you of one of the ways to replace values in dataframe based on some condition - .where function.

1
df['col_name'].where(~(condition), inplace = True, other = values_to_replace)
copy

Using the following approach all the values in col_name will be replaced with values_to_replace if (condition) is True.

Tarea

  1. For all the trips with negative duration add 12 hours to dropoff_datetime column.
  2. Calculate column duration again.
  3. Print first 5 rows of updated df.

Tarea

  1. For all the trips with negative duration add 12 hours to dropoff_datetime column.
  2. Calculate column duration again.
  3. Print first 5 rows of updated df.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 4. Capítulo 7
toggle bottom row

Challenge: Fixing the Issues

Well, in the last chapter you saw, that there were only two rides with negative durations where minutes in both columns were different. But if paid your attention to seconds, you might notice, that that were the minute ending and starting (59 seconds, and 00 respectively). It means that all the inconsistencies can be interpreted as misuages of 12 and 24-hour formats.

Since we have investigated the real reason for the issue, we can now fix it! Let me remind you of one of the ways to replace values in dataframe based on some condition - .where function.

1
df['col_name'].where(~(condition), inplace = True, other = values_to_replace)
copy

Using the following approach all the values in col_name will be replaced with values_to_replace if (condition) is True.

Tarea

  1. For all the trips with negative duration add 12 hours to dropoff_datetime column.
  2. Calculate column duration again.
  3. Print first 5 rows of updated df.

Tarea

  1. For all the trips with negative duration add 12 hours to dropoff_datetime column.
  2. Calculate column duration again.
  3. Print first 5 rows of updated df.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Well, in the last chapter you saw, that there were only two rides with negative durations where minutes in both columns were different. But if paid your attention to seconds, you might notice, that that were the minute ending and starting (59 seconds, and 00 respectively). It means that all the inconsistencies can be interpreted as misuages of 12 and 24-hour formats.

Since we have investigated the real reason for the issue, we can now fix it! Let me remind you of one of the ways to replace values in dataframe based on some condition - .where function.

1
df['col_name'].where(~(condition), inplace = True, other = values_to_replace)
copy

Using the following approach all the values in col_name will be replaced with values_to_replace if (condition) is True.

Tarea

  1. For all the trips with negative duration add 12 hours to dropoff_datetime column.
  2. Calculate column duration again.
  3. Print first 5 rows of updated df.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 4. Capítulo 7
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt