def test_compress_series(series, before, expected, inference): assert series.dtype == before compressed_series = compress_func( series, typeset=StandardSet(), compressor=SparseCompressor(), with_inference=inference, inplace=False, ) assert compressed_series.dtype == expected
def test_copy_frame(): df = pd.DataFrame({"column": pd.Series([1], dtype="int64")}) compressed_df = compress_func( df, typeset=StandardSet(), compressor=DefaultCompressor(), with_inference=True, inplace=False, ) assert id(df) != id(compressed_df)
def test_compress_series(series, before, expected): assert series.dtype == before compressed_series = compress_func( series, typeset=StandardSet(), compressor=DefaultCompressor(), with_inference=True, inplace=False, ) assert str(compressed_series.dtype) == expected assert_series_equal(series, compressed_series, check_dtype=False)
def _( data: pd.Series, typeset: VisionsTypeset, compressor: BaseTypeCompressor, with_inference: bool, units: str = "megabytes", ) -> None: before = data.dtype compressed = compress_func(data, typeset, compressor, with_inference) after = compressed.dtype if str(before) != str(after): print( f'{data.name}: converting from {before} to {after} saves {savings(data, compressed, units)} (use `data[{data.name}].astype("{after}")`)' )