Welcome to safegraph-data-utilities’s documentation!

class sg_data.SafegraphClient(bucket='sg-c19-response', prefix='monthly-patterns', access_key=None, secret_key=None)

Client streamlining process of retrieving data from AWS S3 and preparing a proejct for analysis.

get_dataframe_from_remote_path(source_s3_path)

Get a dataframe for a resource using the remove path, the, “Key,” referncing the path within the bucket in AWS S3.

get_patterns_dataframe(year, month=None, safegraph_pois=None, placekeys=None)

Get a patterns dataframe for a specific month and year with the option (recommended) to filter to a specific point of interest using the Safegraph POI ID. A combination of both year and month filters can be used to select just a single season from multiple years.

Parameters
  • year – Required Year(s) to retrieve.

  • month – Optional Month(s) to retrieve.

  • safegraph_pois – Optional Safegraph point-of-interest id’s used to filter the data.

  • placekeys – Optional Placekeys used to filter the data.

Returns

Dataframe of Safegraph patterns data.

from sg_data import SafegraphClient

sg_poi = 'sg:af471021a929414cbf69854e6f8f1b0c'  # white pass ski area

sg = SafegraphClient()

# just getting the months the ski area is open for two consecutive years
wp_df = sg.get_patterns_dataframe([2018, 2019], [11, 12, 1, 2, 3, 4]

Indices and tables