ipumspy.api.MicrodataExtract#
- class ipumspy.api.MicrodataExtract(collection, samples, variables, description='', data_format='fixed_width', data_structure={'rectangular': {'on': 'P'}}, time_use_variables=None, **kwargs)[source]#
Class for defining an extract for an IPUMS microdata collection.
- Parameters:
collection (
str) – name of an IPUMS data collectionsamples (
Union[List[str],List[Sample]]) – list of sample IDs from an IPUMS microdata collectionvariables (
Union[List[str],List[Variable]]) – list of variable names from an IPUMS microdata collectiondescription (
str) – short description of your extractdata_format (
str) – fixed_width and csv supporteddata_structure (
Dict) – nested dict with “rectangular”, “hierarchical”, or “household-only” 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.time_use_variables (
Union[List[str],List[TimeUseVariable],None]) – a list of IPUMS Time Use Variable names or Objects. This argument is only valid for IPUMS ATUS, MTUS, and AHTUS data collections. If the list contains user-created Time Use Variables, these must be passed as a list of TimeUseVariable objects with the ‘owner’ field specified.
- Keyword Arguments:
data_quality_flags – a boolean value which, if True, adds the data quality flags for each variable included in the variables list if a data quality flag exists for that variable.
sample_members – a dictionary of non-default sample members to include for Time Use collections where keys are strings indicating sample member type and values are boolean. This argument is only valid for IPUMS ATUS, MTUS, and AHTUS data collections. Valid keys include ‘include_non_respondents’ and ‘include_household_members’.
case_select_who – indicates how to interpret any case selections included for variables in the extract.
"individuals"includes records for all individuals who match the specified case selections, while"households"includes records for all members of each household that contains an individual who matches the specified case selections.
Attributes
collection_typeIPUMS collection type
extract_idThe extract id associated with this extract, assigned by the
IpumsApiClientextract_infoThe API response recieved by the
IpumsApiClientapi_versionIPUMS API version number
Methods
Class for defining an extract for an IPUMS microdata collection.
A method to update existing IPUMS Extract Variable objects to include that variable's data quality flag in the extract if it exists.
A method to update existing IPUMS Extract Variable objects to include that variable's inflation-adjusted version in the extract if possible.
A method to update existing IPUMS Extract Variable objects with the IPUMS attach characteristics feature.
Convert the object into a dictionary to be passed to the IPUMS API as a JSON string
A method to update existing IPUMS Extract Variable objects to select cases with the specified values of that IPUMS variable.