classrooms module
- class classrooms.Address(**kwargs: str)
Bases:
object
Address object made from informations retrieved via ADE API.
- Parameters
kwargs (str) – dict with minimal entries (can be None): - address1 - zipCode - city - country
- Example
>>> informations = dict(address1='Rue Rose 42', zipCode='1300', city='Wavre', country='Belgique') >>> address = Address(**informations)
- class classrooms.Classroom(**kwargs: Union[str, classrooms.Address])
Bases:
object
Classroom object containing the address (as string or Address object), the name of the classroom and its id.
- Parameters
kwargs (Union[str, Address]) – dict with minimal entries: - address - name - id
Its main purpose is be used with
location()
.- location() str
Returns the location (address) of this classroom.
- Returns
the location
- Return type
str
- classrooms.get_geo_locations() Dict
Returns the dictionary mapping each address to its geo-location.
- Returns
the geo-locations
- Return type
Dict
- classrooms.merge_classrooms(classrooms: Iterable[classrooms.Classroom]) classrooms.Classroom
Merges multiple classrooms into one.
- Parameters
classrooms (Iterable[Classroom]) – multiple classrooms
- Returns
the new classroom
- Return type
- Example
>>> c1 = Classroom(address1, 'classA', 1) >>> c2 = Classroom(address2, 'classB', 2) >>> c3 = merge_classrooms((c1, c2))
- classrooms.prettify_classrooms(classrooms: pandas.core.frame.DataFrame, sleep: float = 0) pandas.core.frame.DataFrame
Returns the classrooms dataframe in a pretty format, useful when need to display.
The function will request, for every different address, a geo-localisation, so it can take some times. If too many requests are done, Nominatim will not like it so prefer to put a time.sleep between each request.
- Parameters
classrooms (pd.DataFrame) – the classrooms with fields defined in backend.resources.py
sleep (float) – the sleep duration between each address request
- Returns
the classrooms in a prettier format and with geo-location information
- Return type
pd.DataFrame
- classrooms.save_geo_locations(geo_locations: Dict)
Saves the dictionary of geo-locations into a json file with pretty indent. This file can be manually edited without causing any problem.
- Parameters
geo_locations (Dict) – the geo-locations