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

Method test_decimal_point

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

Source from the content-addressed store, hash-verified

1054 }
1055
1056 def test_decimal_point(self):
1057 # Infer floats with a custom decimal point
1058 parse_options = ParseOptions(delimiter=';')
1059 rows = b"a;b\n1.25;2,5\nNA;-3\n-4;NA"
1060
1061 table = self.read_bytes(rows, parse_options=parse_options)
1062 schema = pa.schema([('a', pa.float64()),
1063 ('b', pa.string())])
1064 assert table.schema == schema
1065 assert table.to_pydict() == {
1066 'a': [1.25, None, -4.0],
1067 'b': ["2,5", "-3", "NA"],
1068 }
1069
1070 convert_options = ConvertOptions(decimal_point=',')
1071 table = self.read_bytes(rows, parse_options=parse_options,
1072 convert_options=convert_options)
1073 schema = pa.schema([('a', pa.string()),
1074 ('b', pa.float64())])
1075 assert table.schema == schema
1076 assert table.to_pydict() == {
1077 'a': ["1.25", "NA", "-4"],
1078 'b': [2.5, -3.0, None],
1079 }
1080
1081 def test_simple_timestamps(self):
1082 # 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