casting.py 717 B

1234567891011121314151617181920212223
  1. import pandas as pd
  2. from pandas.core.internals import ObjectBlock
  3. from .base import BaseExtensionTests
  4. class BaseCastingTests(BaseExtensionTests):
  5. """Casting to and from ExtensionDtypes"""
  6. def test_astype_object_series(self, all_data):
  7. ser = pd.Series({"A": all_data})
  8. result = ser.astype(object)
  9. assert isinstance(result._data.blocks[0], ObjectBlock)
  10. def test_tolist(self, data):
  11. result = pd.Series(data).tolist()
  12. expected = list(data)
  13. assert result == expected
  14. def test_astype_str(self, data):
  15. result = pd.Series(data[:5]).astype(str)
  16. expected = pd.Series(data[:5].astype(str))
  17. self.assert_series_equal(result, expected)