Esempio n. 1
0
def test_select_x():
    assert utils.select_x(None) is None

    def _check(d, expected):
        x = utils.select_x(d)
        assert x == expected

    data = dict(col1=[1.0, 2.0, 3.0],  # Q
                col2=['A', 'B', 'C'],  # N
                col3=pd.date_range('2012', periods=3, freq='A'))  # T
    _check(data, 'col3')

    data = dict(col1=[1.0, 2.0, 3.0],  # Q
                col2=['A', 'B', 'C'])  # N
    _check(data, 'col2')

    data = dict(col1=[1.0, 2.0, 3.0])  # Q
    _check(data, 'col1')

    # Custom order
    data = dict(col1=[1.0, 2.0, 3.0],  # Q
                col2=['A', 'B', 'C'],  # N
                col3=pd.date_range('2012', periods=3, freq='A'),  # T
                col4=pd.date_range('2012', periods=3, freq='A'))  # T
    selected_x = utils.select_x(data, ['N', 'T', 'Q', 'O'])
    assert selected_x == "col2"

    # Len < 1
    assert utils.select_x(dict()) is None
Esempio n. 2
0
def test_select_x():
    assert utils.select_x(None) is None

    def _check(d, expected):
        x = utils.select_x(d)
        assert x == expected

    data = dict(
        col1=[1.0, 2.0, 3.0],  # Q
        col2=['A', 'B', 'C'],  # N
        col3=pd.date_range('2012', periods=3, freq='A'))  # T
    _check(data, 'col3')

    data = dict(
        col1=[1.0, 2.0, 3.0],  # Q
        col2=['A', 'B', 'C'])  # N
    _check(data, 'col2')

    data = dict(col1=[1.0, 2.0, 3.0])  # Q
    _check(data, 'col1')

    # Custom order
    data = dict(
        col1=[1.0, 2.0, 3.0],  # Q
        col2=['A', 'B', 'C'],  # N
        col3=pd.date_range('2012', periods=3, freq='A'),  # T
        col4=pd.date_range('2012', periods=3, freq='A'))  # T
    selected_x = utils.select_x(data, ['N', 'T', 'Q', 'O'])
    assert selected_x == "col2"

    # Len < 1
    assert utils.select_x(dict()) is None
Esempio n. 3
0
 def _check(d, expected):
     x = utils.select_x(d)
     assert x == expected
Esempio n. 4
0
 def _check(d, expected):
     x = utils.select_x(d)
     assert x == expected