Esempio n. 1
0
def test_get_dimensions():
    """Should return two lists (dimension names and members)."""
    pc_axis = pyaxis.read(data_path + '14001.px', 'iso-8859-15')
    metadata_elements, raw_data = pyaxis.metadata_extract(pc_axis)
    metadata = pyaxis.metadata_split_to_dict(metadata_elements)
    dimension_names, dimension_members = pyaxis.get_dimensions(metadata)
    assert len(dimension_names) == 4
    assert dimension_names[
        0] == 'Comunidad Autónoma de residencia del matrimonio'
    assert dimension_names[3] == 'estado civil anterior de los cónyuges'
    assert len(dimension_members) == 4
    assert dimension_members[0][0] == 'Total'
    assert dimension_members[3][3] == 'Divorciados/as'
Esempio n. 2
0
def test_get_dimensions():
    """Should return two lists (dimension names and members)."""
    pc_axis = pyaxis.read(
        'https://www.ine.es/jaxi/files/_px/es/px/t20/e301/matri/a2000/l0/'
        '14001.px?nocab=1', 'iso-8859-15')
    metadata_elements, raw_data = pyaxis.metadata_extract(pc_axis)
    metadata = pyaxis.metadata_split_to_dict(metadata_elements)
    dimension_names, dimension_members = pyaxis.get_dimensions(metadata)
    assert len(dimension_names) == 4
    assert dimension_names[
        0] == 'Comunidad Autónoma de residencia de los cónyuges'
    assert dimension_names[3] == 'Estado civil anterior de los cónyuges'
    assert len(dimension_members) == 4
    assert dimension_members[0][0] == 'Todas las comunidades'
    assert dimension_members[3][3] == 'Divorciados/as'
Esempio n. 3
0
def test_build_dataframe():
    """Should return a dataframe with n+1 columns (dimensions + data)."""
    null_values = r'^"\."$'
    sd_values = r'"\.\."'
    pc_axis = pyaxis.read(data_path + '14001.px', 'iso-8859-15')
    metadata_elements, raw_data = pyaxis.metadata_extract(pc_axis)
    metadata = pyaxis.metadata_split_to_dict(metadata_elements)
    dimension_names, dimension_members = pyaxis.get_dimensions(metadata)
    data_values = Series(raw_data.split())
    df = pyaxis.build_dataframe(dimension_names,
                                dimension_members,
                                data_values,
                                null_values=null_values,
                                sd_values=sd_values)
    assert df.shape == (8064, 5)
    assert df['DATA'][7] == '28138'
    assert df['DATA'][159] == '422'
Esempio n. 4
0
def test_build_dataframe():
    """Should return a dataframe with n+1 columns (dimensions + data)."""
    null_values = r'^"\."$'
    sd_values = r'"\.\."'
    pc_axis = pyaxis.read(
        'https://www.ine.es/jaxi/files/_px/es/px/t20/e301/matri/a2000/l0/'
        '14001.px?nocab=1', 'iso-8859-15')
    metadata_elements, raw_data = pyaxis.metadata_extract(pc_axis)
    metadata = pyaxis.metadata_split_to_dict(metadata_elements)
    dimension_names, dimension_members = pyaxis.get_dimensions(metadata)
    data_values = Series(raw_data.split())
    df = pyaxis.build_dataframe(dimension_names,
                                dimension_members,
                                data_values,
                                null_values=null_values,
                                sd_values=sd_values)
    assert df.shape == (8064, 5)
    assert df['DATA'][7] == '10624.0'
    assert df['DATA'][159] == '534.0'