Location date features as dataframe
Project description
SpaceTimePandas
Location and date features from a bunch of api sources to Pandas. Repository hosted on GitHub.
pip install SpaceTimePandas
Temporal features
>>> import datetime
>>> from stpd.event import Holiday
>>> Holiday('US')(datetime.date(2022, 1, 17))
{
'us_holiday_days_since_last': 0,
'us_holiday_days_to_next': 35
}
>>> from datetime import datetime
>>> from stpd.fourier import Fourier
>>> Fourier()(datetime(2020, 1, 1))
{
'week_of_year_sine_phase_0': 0.1198805403706726,
...
'week_of_year_sine_phase_52': 0.08569582503232778,
'week_of_year_cos_phase_0': 0.9927883238840168,
...
'minute_of_hour_cos_phase_59': 0.9945218953682733
}
Location features
>>> from stpd.openstreetmap import OpenStreetMap
>>> osm=OpenStreetMap()('Toronto Ontario')
[nominatim] downloading data: search
{
'count_natural=tree': 719,
'count_natural=water': 15,
'count_building=yes': 1151,
'count_building=house': 39,
'count_amenity=parking': 148,
'count_amenity=restaurant': 327,
'count_service=driveway': 77
}
>>> from stpd.openrouteservice import OpenRouteServicePathFeatures
>>> ors = OpenRouteServicePathFeatures(api_key='<GET-ONE-FROM-OPENROUTESERVICE>')
>>> ors(location_strs=['toronto ontario', 'hamilton ontario'])
{
'distance': 67828.8,
'duration': 3125.3
}
>>> from stpd.openrouteservice import OpenRouteServiceLocationFeatures
>>> ors = OpenRouteServiceLocationFeatures(api_key='<GET-ONE-FROM-OPENROUTESERVICE>')
>>> ors(location_str='toronto ontario')
{
'range_seconds_100.0_area': 553988.44,
'range_seconds_100.0_reachfactor': 0.0229,
'range_seconds_100.0_total_pop': 1953.0,
'range_seconds_200.0_area': 3674992.8,
...
'range_seconds_1000.0_total_pop': 942521.0
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
SpaceTimePandas-0.3.1.tar.gz
(27.4 kB
view hashes)
Built Distribution
Close
Hashes for SpaceTimePandas-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85337ed45da2323fb8022cde0e50090e4416e68a27dec2cfa2f5e86a07158321 |
|
MD5 | d273f2741d57bb8e70c545da4fa9c373 |
|
BLAKE2b-256 | d977c10e35b4abcf73995d60c604feef2887f8207b1998d3a64f14af9da4508a |