Company: KLA
Difficulty: medium
Problem Description Given a pandas DataFrame containing a dataset of taxi rides, write a Python function longestRide(df) to process the data as follows: Drop all rows where either the pickup time or dropoff time is missing (NaN/null). Calculate the duration of each ride (difference between dropoff and pickup times). Find the longest ride (by duration) for each pickup month. The pickup month must be formatted as a string YYYY-MM . If there is a tie for the longest ride duration within a single month, select the ride with the lexicographically smaller id . Sort the resulting data by the pickup month in ascending order. Input The function takes a single parameter df , a pandas DataFrame containing the following columns: id (string): A unique trip identifier. vendor_id (string/int): An identifier for the taxi vendor. pickup_datetime (string): The date and time when the ride started (e.g., "2016-06-06 06:06:20" ). dropoff_datetime (string): The date and time when the ride ended (e.g., "2016