Implement a function to calculate the moving average of a dataset.
Given a non-empty list of numbers and a positive window size, return the average for every contiguous window of that size. Return an empty list when the window is larger than the dataset. Use a sliding-window approach so each value is added and removed at most once.
Signature: def moving_average(data, window_size):
Example: data = [1, 2, 3, 4], window_size = 3 returns [2.0, 3.0].
def moving_average(data, window_size):