<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calculate_bmi(closed, submitted):
 """ BMI is the ratio of the number of closed items to the number of total items submitted in a particular period of analysis. The items can be issues, pull requests and such :param closed: dataframe returned from get_timeseries() containing closed items :param submitted: dataframe returned from get_timeseries() containing total items :returns: a dataframe with "date" and "bmi" columns where the date column is also the index. bmi is the ratio of the number of items closed by the total number of items submitted in a "period" of analysis """


    if sorted(closed.keys()) != sorted(submitted.keys()):
        raise AttributeError("The buckets supplied are not congruent!")

    dates = closed.index.values
    closed_values = closed['value']
    submitted_values = submitted['value']
    ratios = []
    for x, y in zip(closed_values, submitted_values):
        if y == 0:
            ratios.append(0.0)
        else:
            ratios.append(float("%.2f" % (x / y)))

    df = pd.DataFrame.from_records({"date": dates, "bmi": ratios}, index="date")
    return df.fillna(0)