#C12348. Bike Rentals Analysis

    ID: 41765 Type: Default 1000ms 256MiB

Bike Rentals Analysis

Bike Rentals Analysis

You are given a CSV dataset containing bike rental information. The dataset includes the following columns:

  • datetime (format: \(YYYY-MM-DD\ HH:MM:SS\))
  • season
  • weather
  • temp
  • humidity
  • windspeed
  • casual
  • registered
  • count

Your task is to process the data as follows:

  1. Parse the datetime column and extract the hour (an integer from 0 to 23).
  2. Group the records by the extracted hour.
  3. Compute the average values of count, casual, and registered for each hour. The averages should be rounded to two decimal places.
  4. Output the results sorted by hour in ascending order. For each hour, print a line with four values: hour, average count, average casual, and average registered, separated by a single space.</p>

    inputFormat

    The input is provided from standard input (stdin) and consists of multiple lines in CSV format. The first line is the header. Each subsequent line contains the following fields separated by commas:

    • datetime
    • season
    • weather
    • temp
    • humidity
    • windspeed
    • casual
    • registered
    • count

    outputFormat

    For each unique hour found in the dataset, output a line to standard output (stdout) containing four values separated by a space:

    • hour
    • average count (rounded to two decimals)
    • average casual (rounded to two decimals)
    • average registered (rounded to two decimals)

    The output should be sorted by hour in increasing order.

    ## sample
    datetime,season,weather,temp,humidity,windspeed,casual,registered,count
    2023-10-01 00:00:00,1,1,14.76,81,0.0,3,13,16
    2023-10-01 01:00:00,1,1,13.94,80,0.0,4,32,36
    2023-10-01 02:00:00,1,1,13.76,79,0.0,2,22,24
    0 16.00 3.00 13.00
    

    1 36.00 4.00 32.00 2 24.00 2.00 22.00

    </p>