0
0
Data Analysis Pythondata~10 mins

Date-based indexing and slicing in Data Analysis Python - Interactive Code Practice

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

Complete the code to select data for January 2023 using date-based indexing.

Data Analysis Python
january_data = df.loc[[1]]
Drag options to blanks, or click blank then click option'
A'2022-12'
B'2023-01'
C'2023-02'
D'2023-03'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a date string for the wrong month.
Forgetting to use quotes around the date string.
2fill in blank
medium

Complete the code to slice the DataFrame for dates from March 1 to March 10, 2023.

Data Analysis Python
march_slice = df.loc[[1]:'2023-03-10']
Drag options to blanks, or click blank then click option'
A'2023-02-28'
B'2023-03-11'
C'2023-03-01'
D'2023-04-01'
Attempts:
3 left
💡 Hint
Common Mistakes
Starting the slice before the desired date range.
Using a date after the end date as the start.
3fill in blank
hard

Fix the error in the code to select data for the year 2022.

Data Analysis Python
year_data = df.loc[[1]]
Drag options to blanks, or click blank then click option'
A'2022-00'
B'2022-13'
C'2022-01-01 to 2022-12-31'
D'2022'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a range string instead of a single date string.
Using invalid month numbers like 13 or 00.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 4 characters.

Data Analysis Python
lengths = {word: [1] for word in words if len(word) [2] 4}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length.
Using less than instead of greater than in the condition.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values greater than 0.

Data Analysis Python
result = { [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase keys instead of uppercase.
Using incorrect comparison operators like '<' or '='.