Skip to content

Commit

Permalink
COMPAT: Update old numpy aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Oct 9, 2023
1 parent e74138c commit 2180112
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ def __init__(self) -> None:
# with a label, but the underlying variable is -127 to 100
# we're going to drop the label and cast to int
self.DTYPE_MAP = dict(
list(zip(range(1, 245), [np.dtype("a" + str(i)) for i in range(1, 245)]))
[(i, np.dtype(f"S{i}")) for i in range(1, 245)]
+ [
(251, np.dtype(np.int8)),
(252, np.dtype(np.int16)),
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/constructors/test_from_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def test_frame_from_records_utc(self):

def test_from_records_to_records(self):
# from numpy documentation
arr = np.zeros((2,), dtype=("i4,f4,a10"))
arr = np.zeros((2,), dtype=("i4,f4,S10"))
arr[:] = [(1, 2.0, "Hello"), (2, 3.0, "World")]

DataFrame.from_records(arr)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/reshape/concat/test_append.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ def test_append_length0_frame(self, sort):
tm.assert_frame_equal(df5, expected)

def test_append_records(self):
arr1 = np.zeros((2,), dtype=("i4,f4,a10"))
arr1 = np.zeros((2,), dtype=("i4,f4,S10"))
arr1[:] = [(1, 2.0, "Hello"), (2, 3.0, "World")]

arr2 = np.zeros((3,), dtype=("i4,f4,a10"))
arr2 = np.zeros((3,), dtype=("i4,f4,S10"))
arr2[:] = [(3, 4.0, "foo"), (5, 6.0, "bar"), (7.0, 8.0, "baz")]

df1 = DataFrame(arr1)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/methods/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,12 @@ def test_astype_unicode(self):
# bytes with obj.decode() instead of str(obj)
item = "野菜食べないとやばい"
ser = Series([item.encode()])
result = ser.astype("unicode")
result = ser.astype(np.str_)
expected = Series([item])
tm.assert_series_equal(result, expected)

for ser in test_series:
res = ser.astype("unicode")
res = ser.astype(np.str_)
expec = ser.map(str)
tm.assert_series_equal(res, expec)

Expand Down

0 comments on commit 2180112

Please sign in to comment.