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

Method test_write_infer

pandas/tests/io/test_pickle.py:352–373  ·  view source on GitHub ↗
(self, compression_ext, get_random_path, temp_file)

Source from the content-addressed store, hash-verified

350 df.to_pickle(path, compression=compression)
351
352 def test_write_infer(self, compression_ext, get_random_path, temp_file):
353 p1 = temp_file.parent / f"{temp_file.stem}{compression_ext}"
354 p2 = temp_file.parent / f"{temp_file.stem}.raw"
355 compression = self._extension_to_compression.get(compression_ext.lower())
356 df = DataFrame(
357 1.1 * np.arange(120).reshape((30, 4)),
358 columns=Index(list("ABCD"), dtype=object),
359 index=Index([f"i-{i}" for i in range(30)], dtype=object),
360 )
361
362 # write to compressed file by inferred compression method
363 df.to_pickle(p1)
364
365 # decompress
366 with tm.decompress_file(p1, compression=compression) as f:
367 with open(p2, "wb") as fh:
368 fh.write(f.read())
369
370 # read decompressed file
371 df2 = pd.read_pickle(p2, compression=None)
372
373 tm.assert_frame_equal(df, df2)
374
375 def test_read_explicit(self, compression, get_random_path, temp_file):
376 p1 = temp_file.parent / f"{temp_file.stem}.raw"

Callers

nothing calls this directly

Calls 8

DataFrameClass · 0.90
IndexClass · 0.90
lowerMethod · 0.80
to_pickleMethod · 0.80
getMethod · 0.45
reshapeMethod · 0.45
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected