Pandasdrill

Level 2: Cleaning Exercise 18 of 45 Pro

Dates with to_datetime and dt

A pandas exercise from Pandasdrill. Solve it with a Python editor in your browser running real pandas, and it is checked the moment you submit.

The task

The `joined` column holds dates as text. Return a DataFrame with the columns `user`, `month` (the month number) and `weekday` (the full day name, like Monday).

What this exercise teaches

Once the column is a datetime, the .dt accessor exposes parts of each date. dt.month gives 1 to 12, and dt.day_name() gives the weekday as text, while dt.dayofweek would give a number from 0 for Monday.

A hint if you get stuck

pd.to_datetime turns text into dates. After that, .dt.month and .dt.day_name() read parts of each date.

This exercise is part of Pro

Pro unlocks all 45 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.

You create a free account first, so Pro is attached to it.

Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.

Start with the free exercises

More exercises in Cleaning