Visualizing Geographic Data 10.0 Displaying Great Circles

Why did I get an error when running the code below?

fig, ax = plt.subplots(figsize=(15,20))
m = Basemap(projection='merc', llcrnrlat=-80, urcrnrlat=80, llcrnrlon=-180, urcrnrlon=180)

# Start writing your solution below this line

def create_great_circles(df):
    for row in df:
        if (abs(row[end_lat]-(row[start_lat]) < 180) and (abs(row[end_lon]-row[start_lon])<180):
dfw = geo_routes[geo_routes['source'] == 'DFW']

And in the standard answer below, what does for index,row in df.iterrows(): mean? Can I just use for row in df.iterrows(): because I didn’t see index was used anywhere in the function.

def create_great_circles(df):
    for index,row in df.iterrows():
        end_lat, start_lat = row['end_lat'], row['start_lat']
        end_lon, start_lon = row['end_lon'], row['start_lon']
        if abs(end_lat - start_lat) < 180:
            if abs(end_lon - start_lon) < 180:
                m.drawgreatcircle(start_lon, start_lat, end_lon, end_lat)
dfw = geo_routes[geo_routes['source'] == 'DFW']

hi @gaoweidong999

have you tried the print command for row variable from the for loop?

This will assign only the dataframe column names to row variable.

For understanding, different methods of iterations that can be done on a dataframe you may refer to the official documentation for iterations on data.

this article is helpful for .iterrows() method only.