MCPcopy Create free account
hub / github.com/apache/arrow / test_decimal_point

Method test_decimal_point

python/pyarrow/tests/test_csv.py:1040–1063  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1038 }
1039
1040 def test_decimal_point(self):
1041 # Infer floats with a custom decimal point
1042 parse_options = ParseOptions(delimiter=';')
1043 rows = b"a;b\n1.25;2,5\nNA;-3\n-4;NA"
1044
1045 table = self.read_bytes(rows, parse_options=parse_options)
1046 schema = pa.schema([('a', pa.float64()),
1047 ('b', pa.string())])
1048 assert table.schema == schema
1049 assert table.to_pydict() == {
1050 'a': [1.25, None, -4.0],
1051 'b': ["2,5", "-3", "NA"],
1052 }
1053
1054 convert_options = ConvertOptions(decimal_point=',')
1055 table = self.read_bytes(rows, parse_options=parse_options,
1056 convert_options=convert_options)
1057 schema = pa.schema([('a', pa.string()),
1058 ('b', pa.float64())])
1059 assert table.schema == schema
1060 assert table.to_pydict() == {
1061 'a': ["1.25", "NA", "-4"],
1062 'b': [2.5, -3.0, None],
1063 }
1064
1065 def test_simple_timestamps(self):
1066 # Infer a timestamp column

Callers

nothing calls this directly

Calls 5

read_bytesMethod · 0.95
ParseOptionsClass · 0.90
ConvertOptionsClass · 0.90
schemaMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected