Missing example

Screen Link: https://app.dataquest.io/m/292/exploring-data-with-pandas%3A-intermediate/11/using-loops-with-pandas

Your Code: Enclose your code in 3 backticks like this to format properly: your code

What I expected to happen:

What actually happened: wrap your code in triple backticks to format properly

Other details:

The example provided is not complete. It is missing the average calculation.

Hi @erivero,

I am seeing this example code on my end:

# Create an empty dictionary to store the results
avg_rev_by_country = {}

# Create an array of unique countries
countries = f500["country"].unique()

# Use a for loop to iterate over the countries
for c in countries:
    # Use boolean comparison to select only rows that
    # correspond to a specific country
    selected_rows = f500[f500["country"] == c]
    # Calculate the mean average revenue for just those rows
    mean = selected_rows["revenues"].mean()
    # Assign the mean value to the dictionary, using the
    # country name as the key
    avg_rev_by_country[c] = mean
{'Australia': 33688.71428571428,
 'Belgium': 45905.0,
 'Brazil': 52024.57142857143,
 'Britain': 51588.708333333336,
 'Canada': 31848.0,
 'China': 55397.880733944956,
 'Denmark': 35464.0,

Are you not able to see the above code?


Sorry Sahil,

I was out for a while. Yes, you are right.

I had a problem with my browser.


1 Like