Your question is Normalize Energy Usage Data from CSV. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
You are given a complex CSV file representing energy usage data, where each row contains the following fields: timestamp, location, energy_usage_kwh, and energy_type. Your task is to parse this CSV data and normalize the energy_usage_kwh by converting it to megawatt-hours (MWh) and rounding to two decimal places. Additionally, filter out entries with negative energy usage values.
csv_data representing the CSV content.timestamp, location, and energy_usage_mwh.Example 1:
Input: "timestamp,location,energy_usage_kwh,energy_type
2023-01-01T00:00:00Z,LocationA,1500,solar
2023-01-01T01:00:00Z,LocationB,-500,wind"
Output: [{'timestamp': '2023-01-01T00:00:00Z', 'location': 'LocationA', 'energy_usage_mwh': 1.5}]
Example 2:
Input: "timestamp,location,energy_usage_kwh,energy_type
2023-01-01T00:00:00Z,LocationC,3000,solar"
Output: [{'timestamp': '2023-01-01T00:00:00Z', 'location': 'LocationC', 'energy_usage_mwh': 3.0}]
energy_usage_kwh values are integers, which can be negative or positive.def normalize_energy_usage(csv_data):