Generation

generate functionWed, 18 Jan 2023

Fix this function so that when it finds a value in a Pandas dataframe string, it returns its key: def geo_class(row): geo_data = {'center': ['Moscow', 'Tula', 'Yaroslavl'], 'Northwest': ['petersburg', 'pskov', 'murmansk'], 'Far East': ['vladivostok', 'sakhalin', 'khabarovsk']} for key in geo_data.keys(): for value in geo_data.values(): if value in row: return key return 'undefined'

def geo_class(row): geo_data = {'center': ['Moscow', 'Tula', 'Yaroslavl'], 'Northwest': ['petersburg', 'pskov', 'murmansk'], 'Far East': ['vladivostok', 'sakhalin', 'khabarovsk']} for key in geo_data.keys(): if row in geo_data[key]: return key return 'undefined'

Questions about programming?Chat with your personal AI assistant