MCPcopy
hub / github.com/pandas-dev/pandas / test_arrow_from_string

Function test_arrow_from_string

pandas/tests/arrays/string_/test_string.py:383–401  ·  view source on GitHub ↗
(using_infer_string)

Source from the content-addressed store, hash-verified

381
382@pytest.mark.filterwarnings("ignore:Passing a BlockManager:DeprecationWarning")
383def test_arrow_from_string(using_infer_string):
384 # not roundtrip, but starting with pyarrow table without pandas metadata
385 pa = pytest.importorskip("pyarrow")
386 table = pa.table({"a": pa.array(["a", "b", None], type=pa.string())})
387
388 result = table.to_pandas()
389
390 if not using_infer_string:
391 if pa_version_under19p0:
392 expected = pd.DataFrame({"a": ["a", "b", None]}, dtype="object")
393 else:
394 expected = pd.DataFrame(
395 {"a": ["a", "b", None]}, dtype=pd.StringDtype(na_value=np.nan)
396 )
397 elif pa_version_under19p0:
398 expected = pd.DataFrame({"a": ["a", "b", None]}, dtype="object")
399 else:
400 expected = pd.DataFrame({"a": ["a", "b", None]}, dtype="str")
401 tm.assert_frame_equal(result, expected)
402
403
404@pytest.mark.filterwarnings("ignore:Passing a BlockManager:DeprecationWarning")

Callers

nothing calls this directly

Calls 3

tableMethod · 0.80
stringMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected