test_list.py 668 B

123456789101112131415161718192021222324252627282930313233
  1. import pytest
  2. import pandas as pd
  3. from pandas.tests.extension.list.array import (
  4. ListArray,
  5. ListDtype,
  6. make_data,
  7. )
  8. @pytest.fixture
  9. def dtype():
  10. return ListDtype()
  11. @pytest.fixture
  12. def data():
  13. """Length-100 ListArray for semantics test."""
  14. data = make_data()
  15. while len(data[0]) == len(data[1]):
  16. data = make_data()
  17. return ListArray(data)
  18. def test_to_csv(data):
  19. # https://github.com/pandas-dev/pandas/issues/28840
  20. # array with list-likes fail when doing astype(str) on the numpy array
  21. # which was done in to_native_types
  22. df = pd.DataFrame({"a": data})
  23. res = df.to_csv()
  24. assert str(data[0]) in res