()
| 4260 | |
| 4261 | |
| 4262 | def test_dictionary_from_pandas(): |
| 4263 | cat = pd.Categorical(['a', 'b', 'a']) |
| 4264 | expected_type = pa.dictionary( |
| 4265 | pa.int8(), |
| 4266 | pa.large_string() if _pandas_api.uses_string_dtype() else pa.string() |
| 4267 | ) |
| 4268 | |
| 4269 | result = pa.array(cat) |
| 4270 | assert result.to_pylist() == ['a', 'b', 'a'] |
| 4271 | assert result.type.equals(expected_type) |
| 4272 | |
| 4273 | # with missing values in categorical |
| 4274 | cat = pd.Categorical(['a', 'b', None, 'a']) |
| 4275 | |
| 4276 | result = pa.array(cat) |
| 4277 | assert result.to_pylist() == ['a', 'b', None, 'a'] |
| 4278 | assert result.type.equals(expected_type) |
| 4279 | |
| 4280 | # with additional mask |
| 4281 | result = pa.array(cat, mask=np.array([False, False, False, True])) |
| 4282 | assert result.to_pylist() == ['a', 'b', None, None] |
| 4283 | assert result.type.equals(expected_type) |
| 4284 | |
| 4285 | |
| 4286 | def test_dictionary_from_pandas_specified_type(): |
nothing calls this directly
no test coverage detected