def test_decimal_roundtrip(tmpdir, precision): num_values = 10 columns = {} for scale in range(0, precision + 1): with util.random_seed(0): random_decimal_values = [ util.randdecimal(precision, scale) for _ in range(num_values) ] column_name = 'dec_precision_{:d}_scale_{:d}'.format(precision, scale) columns[column_name] = random_decimal_values expected = pd.DataFrame(columns) filename = tmpdir.join('decimals.parquet') string_filename = str(filename) t = pa.Table.from_pandas(expected) _write_table(t, string_filename) result_table = _read_table(string_filename) result = result_table.to_pandas() tm.assert_frame_equal(result, expected)
def test_decimal_roundtrip(tempdir, use_legacy_dataset): num_values = 10 columns = {} for precision in range(1, 39): for scale in range(0, precision + 1): with util.random_seed(0): random_decimal_values = [ util.randdecimal(precision, scale) for _ in range(num_values) ] column_name = ('dec_precision_{:d}_scale_{:d}'.format( precision, scale)) columns[column_name] = random_decimal_values expected = pd.DataFrame(columns) filename = tempdir / 'decimals.parquet' string_filename = str(filename) table = pa.Table.from_pandas(expected) _write_table(table, string_filename) result_table = _read_table(string_filename, use_legacy_dataset=use_legacy_dataset) result = result_table.to_pandas() tm.assert_frame_equal(result, expected)
def test_decimal_roundtrip(tmpdir): num_values = 10 columns = {} for precision in range(1, 39): for scale in range(0, precision + 1): with util.random_seed(0): random_decimal_values = [ util.randdecimal(precision, scale) for _ in range(num_values) ] column_name = ('dec_precision_{:d}_scale_{:d}' .format(precision, scale)) columns[column_name] = random_decimal_values expected = pd.DataFrame(columns) filename = tmpdir.join('decimals.parquet') string_filename = str(filename) t = pa.Table.from_pandas(expected) _write_table(t, string_filename) result_table = _read_table(string_filename) result = result_table.to_pandas() tm.assert_frame_equal(result, expected)