MCPcopy
hub / github.com/pandas-dev/pandas / test1_basic

Method test1_basic

pandas/tests/io/sas/test_xport.py:23–60  ·  view source on GitHub ↗
(self, datapath)

Source from the content-addressed store, hash-verified

21class TestXport:
22 @pytest.mark.slow
23 def test1_basic(self, datapath):
24 # Tests with DEMO_G.xpt (all numeric file)
25
26 # Compare to this
27 file01 = datapath("io", "sas", "data", "DEMO_G.xpt")
28 data_csv = pd.read_csv(file01.replace(".xpt", ".csv"))
29 numeric_as_float(data_csv)
30
31 # Read full file
32 data = read_sas(file01, format="xport")
33 tm.assert_frame_equal(data, data_csv)
34 num_rows = data.shape[0]
35
36 # Test reading beyond end of file
37 with read_sas(file01, format="xport", iterator=True) as reader:
38 data = reader.read(num_rows + 100)
39 assert data.shape[0] == num_rows
40
41 # Test incremental read with `read` method.
42 with read_sas(file01, format="xport", iterator=True) as reader:
43 data = reader.read(10)
44 tm.assert_frame_equal(data, data_csv.iloc[0:10, :])
45
46 # Test incremental read with `get_chunk` method.
47 with read_sas(file01, format="xport", chunksize=10) as reader:
48 data = reader.get_chunk()
49 tm.assert_frame_equal(data, data_csv.iloc[0:10, :])
50
51 # Test read in loop
52 m = 0
53 with read_sas(file01, format="xport", chunksize=100) as reader:
54 for x in reader:
55 m += x.shape[0]
56 assert m == num_rows
57
58 # Read full file with `read_sas` method
59 data = read_sas(file01)
60 tm.assert_frame_equal(data, data_csv)
61
62 def test1_index(self, datapath):
63 # Tests with DEMO_G.xpt using index (all numeric file)

Callers

nothing calls this directly

Calls 7

read_sasFunction · 0.90
datapathFunction · 0.85
numeric_as_floatFunction · 0.85
read_csvMethod · 0.45
replaceMethod · 0.45
readMethod · 0.45
get_chunkMethod · 0.45

Tested by

no test coverage detected