Python Data Engineering test (Intermediate)
30 questions · 35 minutes · Free
NumPy and pandas for cleaning, transforming and moving data.
Take the Python Data Engineering test
What it covers
- NumPy arrays, broadcasting and vectorisation
- pandas indexing and selection
- pandas groupby, merge and pivot
- Missing values, dtypes and dates
Interview format
- Questions: 30 questions — 18 multiple choice, 9 multi-answer, 3 predict-the-output
- Time: 35 minutes, timed from the first question
- Difficulty: Intermediate
- Skill area: Data
- Price: Free
Earn a certificate
The Python Data Engineering test is one of the 5 tests of the Data Analyst learning path. Pass it and the other 4 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.
Sample questions
5 sample questions from the Python Data Engineering test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
A pandas DataFrame contains datetime objects with timezone information. How should you correctly assign a timezone to a naive datetime object and change the timezone of an existing timezone-aware datetime object?
- Use the .tz_localize() method to assign a timezone, and .tz_convert() to change it.
- Use the .tz_localize() method to assign a timezone, and .tz_localize() to change it.
- Use the .convert() method to assign a timezone, and .localize() to change it.
- Use the .tz_convert() method to assign a timezone, and .tz_localize() to change it.
Answer: A. Use the .tz_localize() method to assign a timezone, and .tz_convert() to change it.
When working with timezone-aware datetime objects in pandas, you first use .tz_localize() to assign a timezone to a naive datetime object. If you need to convert the timezone of an existing timezone-aware object, you should use .tz_convert(). Using .convert() or .localize() directly is incorrect because these methods are not part of the pandas datetime API for timezone handling.
What does the apply_along_axis function in NumPy do when it is used with axis=1?
- The function applies the function to the entire array as a single unit.
- The function applies the function to each individual element of the array.
- The function applies the function to each row of the array.
- The function applies the function to each column of the array.
Answer: C. The function applies the function to each row of the array.
The apply_along_axis function in NumPy applies a given function along a specified axis of an array. When the axis is set to 1, the function is applied to each row of the array. This is a key aspect of NumPy's vectorization capabilities, allowing for efficient and concise operations on array data.
Which of the following correctly compares NumPy array slicing with a step parameter and the np.linspace() function?
- Both slice notation with a step parameter and np.linspace() are used to select elements at regular intervals from a NumPy array.
- Using slice notation with a step parameter is less efficient than using np.linspace() for selecting elements from a NumPy array.
- Using slice notation with a step parameter allows precise control over the elements selected, whereas using np.linspace() generates evenly spaced values over a specified interval and is not suitable for arbitrary slicing.
- Slice notation with a step parameter and np.linspace() can be used interchangeably for any slicing operation in NumPy.
Answer: C. Using slice notation with a step parameter allows precise control over the elements selected, whereas using np.linspace() generates evenly spaced values over a specified interval and is not suitable for arbitrary slicing.
When slicing a NumPy array with a step parameter (e.g., arr[start:end:step]), you can select elements at regular intervals, which is useful for tasks like selecting every other element. On the other hand, np.linspace() is used to generate a specified number of evenly spaced values between two endpoints. These are fundamentally different operations and should be used in different contexts. The correct option accurately captures this distinction.
Which of the following statements accurately describes NumPy vectorization with ufuncs?
- NumPy vectorization with ufuncs requires explicit for loops to operate on individual elements of an array.
- NumPy vectorization with ufuncs applies operations to entire arrays without explicit loops, leveraging optimized C-based implementations for performance.
- NumPy vectorization with ufuncs is limited to 1D arrays and cannot handle multi-dimensional data.
- NumPy vectorization with ufuncs is primarily used for string manipulation and does not improve numerical computation performance.
Answer: B. NumPy vectorization with ufuncs applies operations to entire arrays without explicit loops, leveraging optimized C-based implementations for performance.
NumPy vectorization with ufuncs is a core feature that allows operations on entire arrays at once, using highly optimized code written in C. This is different from using explicit loops in Python, which are much slower. The other options either describe incorrect behaviors or are not related to the concept of vectorization.
How does pandas handle timezone-aware datetime objects internally when performing timezone conversions?
- Pandas uses the pytz library for timezone-aware datetime objects and performs conversions based on the timezone definitions in that library.
- Pandas uses the dateutil library for timezone-aware datetime objects and performs conversions based on the timezone definitions in that library.
- Pandas uses the tzdata library for timezone-aware datetime objects and performs conversions based on the timezone definitions in that library.
- Pandas does not support timezone-aware datetime objects and relies on the user to manage timezone conversions manually.
Answer: A. Pandas uses the pytz library for timezone-aware datetime objects and performs conversions based on the timezone definitions in that library.
Pandas uses the pytz library to handle time zones, ensuring accurate conversions and operations with timezone-aware datetime objects. Other options are incorrect as they either describe unrelated libraries, incorrect handling methods, or misrepresent the internal workings of pandas.
Frequently asked questions
- How many questions are in the Python Data Engineering test?
- 30 questions (18 multiple choice, 9 multi-answer, 3 predict-the-output), with 35 minutes to answer them.
- What does the Python Data Engineering test cover?
- NumPy arrays, broadcasting and vectorisation, pandas indexing and selection, pandas groupby, merge and pivot, Missing values, dtypes and dates.
- Is the Python Data Engineering test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Python Data Engineering test?
- Intermediate, in Data.