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

Method test_decimal_point

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

Source from the content-addressed store, hash-verified

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