0
0
Pandasdata~10 mins

Date range creation with date_range in Pandas - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a date range starting from '2024-01-01'.

Pandas
import pandas as pd
dates = pd.date_range(start=[1], periods=5)
print(dates)
Drag options to blanks, or click blank then click option'
A'January 1, 2024'
B'01-01-2024'
C'2024-01-01'
D'2024/01/01'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a date format other than 'YYYY-MM-DD' causes errors or unexpected results.
2fill in blank
medium

Complete the code to create a date range with 7 days starting from '2024-03-01'.

Pandas
import pandas as pd
dates = pd.date_range(start='2024-03-01', [1]=7)
print(dates)
Drag options to blanks, or click blank then click option'
Aperiods
Bend
Cfreq
Dinterval
Attempts:
3 left
💡 Hint
Common Mistakes
Using end instead of periods when specifying number of dates.
3fill in blank
hard

Fix the error in the code to create a date range from '2024-05-01' to '2024-05-10'.

Pandas
import pandas as pd
dates = pd.date_range(start='2024-05-01', [1]='2024-05-10')
print(dates)
Drag options to blanks, or click blank then click option'
Afreq
Bend
Cperiods
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Using periods with a date string instead of a number.
Using non-existent parameters like stop.
4fill in blank
hard

Fill both blanks to create a date range starting from '2024-07-01' with 10 dates spaced every 2 days.

Pandas
import pandas as pd
dates = pd.date_range(start=[1], periods=[2], freq='2D')
print(dates)
Drag options to blanks, or click blank then click option'
A'2024-07-01'
B10
C5
D'2024-07-10'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong number for periods or wrong date format for start.
5fill in blank
hard

Fill all three blanks to create a date range from '2024-09-01' to '2024-09-15' with daily frequency.

Pandas
import pandas as pd
dates = pd.date_range(start=[1], end=[2], freq=[3])
print(dates)
Drag options to blanks, or click blank then click option'
A'2024-09-01'
B'2024-09-15'
C'D'
D'W'
Attempts:
3 left
💡 Hint
Common Mistakes
Using weekly frequency 'W' instead of daily.
Mixing up start and end dates.