import pandas as pd
import pandas._testing as tm
+from pandas.compat import is_platform_little_endian
def test_astype():
tm.assert_numpy_array_equal(result, expected)
result = arr.astype("str")
- expected = np.array(["True", "False", "<NA>"], dtype="<U5")
+ expected = np.array(["True", "False", "<NA>"], dtype="<U5" if is_platform_little_endian() else ">U5")
tm.assert_numpy_array_equal(result, expected)
# no missing values
import pandas._testing as tm
from pandas.arrays import BooleanArray
from pandas.core.arrays.boolean import coerce_to_array
+from pandas.compat import is_platform_little_endian
@pytest.fixture
arr = con([True, False, None], dtype="boolean")
result = arr.to_numpy(dtype="str")
- expected = np.array([True, False, pd.NA], dtype="<U5")
+ expected = np.array([True, False, pd.NA], dtype="<U5" if is_platform_little_endian() else ">U5")
tm.assert_numpy_array_equal(result, expected)
# no missing values -> can convert to bool, otherwise raises
import pytest
from pandas.core.dtypes.generic import ABCIndexClass
+from pandas.compat import is_platform_little_endian
import pandas as pd
import pandas._testing as tm
def test_astype_str():
a = pd.array([1, 2, None], dtype="Int64")
- expected = np.array(["1", "2", "<NA>"], dtype="<U21")
+ expected = np.array(["1", "2", "<NA>"], dtype="<U21" if is_platform_little_endian() else ">U21")
tm.assert_numpy_array_equal(a.astype(str), expected)
tm.assert_numpy_array_equal(a.astype("str"), expected)
date_range,
)
import pandas._testing as tm
+from pandas.compat import is_platform_little_endian
class TestDataFrameToRecords:
),
],
)
+ @pytest.mark.xfail(condition=not is_platform_little_endian(),reason="expected values assume little-endian",strict=False)
def test_to_records_dtype(self, kwargs, expected):
# see GH#18146
df = DataFrame({"A": [1, 2], "B": [0.2, 1.5], "C": ["a", "bc"]})
),
],
)
+ @pytest.mark.xfail(condition=not is_platform_little_endian(),reason="expected values assume little-endian",strict=False)
def test_to_records_dtype_mi(self, df, kwargs, expected):
# see GH#18146
result = df.to_records(**kwargs)
tm.assert_almost_equal(result, expected)
+ @pytest.mark.xfail(condition=not is_platform_little_endian(),reason="expected values assume little-endian",strict=False)
def test_to_records_dict_like(self):
# see GH#18146
class DictLike:
"the dtype timedelta64 is not supported for parsing",
dict(dtype={"A": "timedelta64", "B": "float64"}),
),
- ("the dtype <U8 is not supported for parsing", dict(dtype={"A": "U8"})),
+ ("the dtype [<>]U8 is not supported for parsing", dict(dtype={"A": "U8"})),
],
ids=["dt64-0", "dt64-1", "td64", "<U8"],
)
tm.assert_numpy_array_equal(np.array([2]) * td, expected)
msg = (
"ufunc '?multiply'? cannot use operands with types "
- r"dtype\('<m8\[ns\]'\) and dtype\('<m8\[ns\]'\)"
+ r"dtype\('[<>]m8\[ns\]'\) and dtype\('[<>]m8\[ns\]'\)"
)
with pytest.raises(TypeError, match=msg):
td * other