Esempio n. 1
0
def test_to_records_noindex():
    df = DataFrame()
    df["a"] = aa = np.arange(10, dtype=np.int32)
    df["b"] = bb = np.arange(10, 20, dtype=np.float64)

    rec = df.to_records(index=False)
    assert rec.dtype.names == ("a", "b")
    np.testing.assert_array_equal(rec["a"], aa)
    np.testing.assert_array_equal(rec["b"], bb)
Esempio n. 2
0
def test_to_records_withindex():
    df = DataFrame()
    df["a"] = aa = np.arange(10, dtype=np.int32)
    df["b"] = bb = np.arange(10, 20, dtype=np.float64)

    rec_indexed = df.to_records(index=True)
    assert rec_indexed.size == len(aa)
    assert rec_indexed.dtype.names == ("index", "a", "b")
    np.testing.assert_array_equal(rec_indexed["a"], aa)
    np.testing.assert_array_equal(rec_indexed["b"], bb)
    np.testing.assert_array_equal(rec_indexed["index"], np.arange(10))