ipumspy.api.CpsExtract#

class ipumspy.api.CpsExtract(samples, variables, description='My IPUMS CPS extract', data_format='fixed_width', data_structure={'rectangular': {'on': 'P'}}, **kwargs)[source]#

Defining an IPUMS CPS extract.

Parameters:
  • samples (Union[List[str], List[Sample]]) – list of IPUMS CPS sample IDs

  • variables (Union[List[str], List[Variable]]) – list of IPUMS CPS variable names

  • description (str) – short description of your extract

  • data_format (str) – fixed_width and csv supported

  • data_structure (Dict) – nested dict with “rectangular” or “hierarchical” as first-level key. “rectangular” extracts require further specification of “on” : <record type>. Default {“rectangular”: “on”: “P”} requests an extract rectangularized on the “P” record.

Attributes

collection

Name of an IPUMS data collection

extract_id

The extract id associated with this extract, assigned by the IpumsApiClient

extract_info

The API response recieved by the IpumsApiClient

api_version

IPUMS API version number

Methods

__init__

Defining an IPUMS CPS extract.

build

Convert the object into a dictionary to be passed to the IPUMS API as a JSON string