A histogram shows how many wines fall in each alcohol range. A sharper question is: how good are the wines in each bar?
Task: write quality_by_bin(path, column, bins). path is a CSV file that uses semicolons between values. Its header row holds the column names, including column and quality. There are no missing values, and every row counts — repeats included. The starter code includes write_text(path, text), which saves text into a file and returns the path; the tests use it to create each file.
Sort the rows into bins by their column value, using the same rule as ax.hist:
column into bins bins of equal width.Return a list with one entry per bin, from the lowest bin to the highest. Each entry is [count, average]: how many rows landed in that bin (an int), and the average quality of those rows as a float rounded to 2 decimal places. A bin with no rows is [0, None].
column always holds at least two different values, and bins is at least 1.