コード例 #1
0
def test_to_records_raises_when_object_dtypes_present():
    store = PandasDataFrameStore()
    df = pd.DataFrame(data=dict(A=['a', 'b', None, 'c'], B=[1., 2., 3., 4.]), index=range(4))
    with raises(TypeError) as e:
        store.to_records(df)

    assert "Cannot change data-type for object array." in str(e)
コード例 #2
0
def test_to_records_raises_when_object_dtypes_present():
    store = PandasDataFrameStore()
    df = pd.DataFrame(data=dict(A=['a', 'b', None, 'c'], B=[1., 2., 3., 4.]),
                      index=range(4))
    with raises(TypeError) as e:
        store.to_records(df)

    assert "Cannot change data-type for object array." in str(e)
コード例 #3
0
def test_read_multi_index_with_no_ts_info():
    # github #81: old multi-index ts would not have tz info in metadata. Ensure read is not broken
    df = read_str_as_pandas("""index 1 |    index 2 | SPAM
                            2012-09-08 | 2015-01-01 |  1.0
                            2012-09-09 | 2015-01-02 |  1.1
                            2012-10-08 | 2015-01-03 |  2.0""", num_index=2)
    store = PandasDataFrameStore()
    record = store.to_records(df)[0]

    # now take away timezone info from metadata
    record = np.array(record.tolist(), dtype=np.dtype([('index 1', '<M8[ns]'), ('index 2', '<M8[ns]'), ('SPAM', '<f8')],
                                                      metadata={'index': ['index 1', 'index 2'], 'columns': ['SPAM']}))
    assert store._index_from_records(record).equals(df.index)