Skip to content

Commit 6577d26

Browse files
committed
pandas.Categorical.from_array is deprecated
Let's try just calling pandas.Categorical and see if that works...
1 parent 6c73617 commit 6577d26

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

patsy/categorical.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def guess_categorical(data):
134134

135135
def test_guess_categorical():
136136
if have_pandas_categorical:
137-
c = pandas.Categorical.from_array([1, 2, 3])
137+
c = pandas.Categorical([1, 2, 3])
138138
assert guess_categorical(c)
139139
if have_pandas_categorical_dtype:
140140
assert guess_categorical(pandas.Series(c))
@@ -242,15 +242,15 @@ def t(NA_types, datas, exp_finish_fast, exp_levels, exp_contrast=None):
242242
preps += [pandas.Series,
243243
lambda x: C(pandas.Series(x))]
244244
for prep in preps:
245-
t([], [prep(pandas.Categorical.from_array([1, 2, None]))],
245+
t([], [prep(pandas.Categorical([1, 2, None]))],
246246
True, (1, 2))
247247
# check order preservation
248248
t([], [prep(pandas_Categorical_from_codes([1, 0], ["a", "b"]))],
249249
True, ("a", "b"))
250250
t([], [prep(pandas_Categorical_from_codes([1, 0], ["b", "a"]))],
251251
True, ("b", "a"))
252252
# check that if someone sticks a .contrast field onto our object
253-
obj = prep(pandas.Categorical.from_array(["a", "b"]))
253+
obj = prep(pandas.Categorical(["a", "b"]))
254254
obj.contrast = "CONTRAST"
255255
t([], [obj], True, ("a", "b"), "CONTRAST")
256256

patsy/test_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def test_categorical():
580580
data_categ = {"a": C(["a2", "a1", "a2"])}
581581
datas = [data_strings, data_categ]
582582
if have_pandas_categorical:
583-
data_pandas = {"a": pandas.Categorical.from_array(["a1", "a2", "a2"])}
583+
data_pandas = {"a": pandas.Categorical(["a1", "a2", "a2"])}
584584
datas.append(data_pandas)
585585
def t(data1, data2):
586586
def iter_maker():

patsy/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def test_safe_is_pandas_categorical():
664664
assert not safe_is_pandas_categorical(np.arange(10))
665665

666666
if have_pandas_categorical:
667-
c_obj = pandas.Categorical.from_array(["a", "b"])
667+
c_obj = pandas.Categorical(["a", "b"])
668668
assert safe_is_pandas_categorical(c_obj)
669669

670670
if have_pandas_categorical_dtype:

0 commit comments

Comments
 (0)