| 2597 | |
| 2598 | @pytest.mark.numpy |
| 2599 | def test_pandas_null_sentinels_raise_error(): |
| 2600 | # ARROW-6227 |
| 2601 | cases = [ |
| 2602 | ([None, np.nan], 'null'), |
| 2603 | (['string', np.nan], 'binary'), |
| 2604 | (['string', np.nan], 'utf8'), |
| 2605 | (['string', np.nan], 'large_binary'), |
| 2606 | (['string', np.nan], 'large_utf8'), |
| 2607 | ([b'string', np.nan], pa.binary(6)), |
| 2608 | ([True, np.nan], pa.bool_()), |
| 2609 | ([decimal.Decimal('0'), np.nan], pa.decimal128(12, 2)), |
| 2610 | ([0, np.nan], pa.date32()), |
| 2611 | ([0, np.nan], pa.date32()), |
| 2612 | ([0, np.nan], pa.date64()), |
| 2613 | ([0, np.nan], pa.time32('s')), |
| 2614 | ([0, np.nan], pa.time64('us')), |
| 2615 | ([0, np.nan], pa.timestamp('us')), |
| 2616 | ([0, np.nan], pa.duration('us')), |
| 2617 | ] |
| 2618 | for case, ty in cases: |
| 2619 | # Both types of exceptions are raised. May want to clean that up |
| 2620 | with pytest.raises((ValueError, TypeError)): |
| 2621 | pa.array(case, type=ty) |
| 2622 | |
| 2623 | # from_pandas option suppresses failure |
| 2624 | result = pa.array(case, type=ty, from_pandas=True) |
| 2625 | assert result.null_count == (1 if ty != 'null' else 2) |
| 2626 | |
| 2627 | |
| 2628 | @pytest.mark.pandas |