benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 5adf6b18-fcda-51f7-8273-e413fde6a0b7

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import pandas as pd
import folium
from geopy.geocoders import Photon

def task_func(dic):
    """
    Generates a Folium map with markers for specified locations. It preprocesses the input to handle
    both direct geographical coordinates and address strings. For address strings, it dynamically resolves
    their latitude and longitude using the Photon geolocation service. This flexible input handling
    allows for easy mapping of various location types.

    Parameters:
        dic (dict): A dictionary with location names as keys. Each key can either map to a dictionary
                    {'Lat': latitude, 'Lon': longitude} for direct coordinates, or to a string indicating
                    the location's address for geolocation lookup using Photon.

    Returns:
        folium.Map: A Folium map object with markers for each specified location.

    Requirements:
    - pandas
    - folium
    - geopy.geocoders.Photon

    Notes:
    - The geolocator, instantiated as Photon(user_agent="geoapiExercises"), plays a crucial role in enabling
    the function to handle string addresses by converting them into latitude and longitude, thus broadening
    the scope of input data that can be mapped.

    Examples:
    >>> locations = {'Place1': {'Lat': 0, 'Lon': 0}, 'Place2': 'New York, USA'}
    >>> result = task_func(locations)
    >>> isinstance(result, folium.Map)
    True
    >>> [0.0, 0.0] == result.location
    True
    """

instruct prompt

Generates a Folium map with markers for specified locations. It preprocesses the input to handle both direct geographical coordinates and address strings. For address strings, it dynamically resolves their latitude and longitude using the Photon geolocation service. This flexible input handling allows for easy mapping of various location types.
Note that: Notes: The geolocator, instantiated as Photon(user_agent="geoapiExercises"), plays a crucial role in enabling the function to handle string addresses by converting them into latitude and longitude, thus broadening the scope of input data that can be mapped.
The function should output with:
    folium.Map: A Folium map object with markers for each specified location.
You should write self-contained code starting with:

Code

import pandas as pd
import folium
from geopy.geocoders import Photon
def task_func(dic):

code prompt

Code

import pandas as pd
import folium
from geopy.geocoders import Photon
def task_func(dic):

entry point

task_func

libs

  • pandas
  • geopy
  • folium

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import