GenericCampaign#
- class fourinsight.campaigns.GenericCampaign(session, campaign_id)[source]#
Generic campaign.
- Parameters:
session (authorized session) – Authorized session instance which appends a valid bearer token to all HTTP calls. Use
fourinsight.api.UserSessionorfourinsight.api.ClientSession.campaign_id (str) – The id of the campaign (GUID).
- events(value=None, by='Event Type')[source]#
Get the events by its event type.
- Parameters:
value – The event type to find. If None, return all events.
(optional) (str) – The event type to find. If None, return all events.
by – What to find. Allowed values are Event Type.
str – What to find. Allowed values are Event Type.
- Returns:
A list containing event dicts. Results are sorted on Start.
- Return type:
list of dicts
- get_sensor_data(drio_client, source, start=None, end=None, filter_=None)[source]#
Download the sensor data into a DataFrame.
The data will be limited to within the campaign start and end time as given in the General section.
- Parameters:
drio_client (datareservoirio.Client) – Datareservoirio client instance.
source (dict) – Source dict. A dict containing a key
channelswith a list of channel dicts.start (str, datetime-like, optional) – start time (inclusive) of the series given as anything pandas.to_datetime is able to parse. Default to campaign start date, or 1970-01-01 if not given.
end (str, datetime-like, optional) – stop time (inclusive) of the series given as anything pandas.to_datetime is able to parse. Default to campaign end date (inclusive), or now if not given.
filter (list of str, optional) – A list of channel names to include in the results. Common options are available in
fourinsight.campaigns.channels. Default to None, meaning all channels.
- Returns:
DataFrame containing the time series for the sensor channels.
- Return type:
pd.DataFrame
Note
You can supply pre-defiend lists from
fourinsight.campaigns.channels. E.g.my_campaign.get_sensor_data(drio_client, lmrp_sensor, filter_=fourinsight.campaigns.channels.AG)to include all acceleration and gyro data.
- sensors(value=None, by='Position')[source]#
Get a sensor by its position or name.
- Parameters:
value – The position (or name) to find. If None, return all sensors.
(optional) (str) – The position (or name) to find. If None, return all sensors.
by – What to find. Allowed values are Position or Name.
str – What to find. Allowed values are Position or Name.
- Returns:
A list containing sensor dicts.
- Return type:
list of dicts