Skip to content

Commit 6f080bd

Browse files
authored
TST/CLN: Remove makeMixedDataFrame and getMixedTypeDict (#56202)
1 parent a38ecd5 commit 6f080bd

File tree

7 files changed

+68
-29
lines changed

7 files changed

+68
-29
lines changed

pandas/_testing/__init__.py

-19
Original file line numberDiff line numberDiff line change
@@ -482,23 +482,6 @@ def makeDataFrame() -> DataFrame:
482482
return DataFrame(data)
483483

484484

485-
def getMixedTypeDict():
486-
index = Index(["a", "b", "c", "d", "e"])
487-
488-
data = {
489-
"A": [0.0, 1.0, 2.0, 3.0, 4.0],
490-
"B": [0.0, 1.0, 0.0, 1.0, 0.0],
491-
"C": ["foo1", "foo2", "foo3", "foo4", "foo5"],
492-
"D": bdate_range("1/1/2009", periods=5),
493-
}
494-
495-
return index, data
496-
497-
498-
def makeMixedDataFrame() -> DataFrame:
499-
return DataFrame(getMixedTypeDict()[1])
500-
501-
502485
def makeCustomIndex(
503486
nentries,
504487
nlevels,
@@ -1026,7 +1009,6 @@ def shares_memory(left, right) -> bool:
10261009
"get_dtype",
10271010
"getitem",
10281011
"get_locales",
1029-
"getMixedTypeDict",
10301012
"get_finest_unit",
10311013
"get_obj",
10321014
"get_op_from_name",
@@ -1042,7 +1024,6 @@ def shares_memory(left, right) -> bool:
10421024
"makeDateIndex",
10431025
"makeFloatIndex",
10441026
"makeIntIndex",
1045-
"makeMixedDataFrame",
10461027
"makeNumericIndex",
10471028
"makeObjectSeries",
10481029
"makePeriodIndex",

pandas/tests/frame/methods/test_transpose.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
from pandas import (
77
DataFrame,
88
DatetimeIndex,
9+
Index,
910
IntervalIndex,
1011
Series,
1112
Timestamp,
13+
bdate_range,
1214
date_range,
1315
timedelta_range,
1416
)
@@ -108,9 +110,17 @@ def test_transpose_float(self, float_frame):
108110
else:
109111
assert value == frame[col][idx]
110112

113+
def test_transpose_mixed(self):
111114
# mixed type
112-
index, data = tm.getMixedTypeDict()
113-
mixed = DataFrame(data, index=index)
115+
mixed = DataFrame(
116+
{
117+
"A": [0.0, 1.0, 2.0, 3.0, 4.0],
118+
"B": [0.0, 1.0, 0.0, 1.0, 0.0],
119+
"C": ["foo1", "foo2", "foo3", "foo4", "foo5"],
120+
"D": bdate_range("1/1/2009", periods=5),
121+
},
122+
index=Index(["a", "b", "c", "d", "e"], dtype=object),
123+
)
114124

115125
mixed_T = mixed.T
116126
for col, s in mixed_T.items():

pandas/tests/io/pytables/test_append.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,14 @@ def check_col(key, name, size):
397397
store.append("df_new", df_new)
398398

399399
# min_itemsize on Series index (GH 11412)
400-
df = tm.makeMixedDataFrame().set_index("C")
400+
df = DataFrame(
401+
{
402+
"A": [0.0, 1.0, 2.0, 3.0, 4.0],
403+
"B": [0.0, 1.0, 0.0, 1.0, 0.0],
404+
"C": pd.Index(["foo1", "foo2", "foo3", "foo4", "foo5"], dtype=object),
405+
"D": date_range("20130101", periods=5),
406+
}
407+
).set_index("C")
401408
store.append("ss", df["B"], min_itemsize={"index": 4})
402409
tm.assert_series_equal(store.select("ss"), df["B"])
403410

pandas/tests/io/pytables/test_store.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,14 @@ def test_to_hdf_with_min_itemsize(tmp_path, setup_path):
323323
path = tmp_path / setup_path
324324

325325
# min_itemsize in index with to_hdf (GH 10381)
326-
df = tm.makeMixedDataFrame().set_index("C")
326+
df = DataFrame(
327+
{
328+
"A": [0.0, 1.0, 2.0, 3.0, 4.0],
329+
"B": [0.0, 1.0, 0.0, 1.0, 0.0],
330+
"C": Index(["foo1", "foo2", "foo3", "foo4", "foo5"], dtype=object),
331+
"D": date_range("20130101", periods=5),
332+
}
333+
).set_index("C")
327334
df.to_hdf(path, key="ss3", format="table", min_itemsize={"index": 6})
328335
# just make sure there is a longer string:
329336
df2 = df.copy().reset_index().assign(C="longer").set_index("C")

pandas/tests/reshape/merge/test_join.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
MultiIndex,
1212
Series,
1313
Timestamp,
14+
bdate_range,
1415
concat,
1516
merge,
1617
)
@@ -57,8 +58,13 @@ def df2(self):
5758

5859
@pytest.fixture
5960
def target_source(self):
60-
index, data = tm.getMixedTypeDict()
61-
target = DataFrame(data, index=index)
61+
data = {
62+
"A": [0.0, 1.0, 2.0, 3.0, 4.0],
63+
"B": [0.0, 1.0, 0.0, 1.0, 0.0],
64+
"C": ["foo1", "foo2", "foo3", "foo4", "foo5"],
65+
"D": bdate_range("1/1/2009", periods=5),
66+
}
67+
target = DataFrame(data, index=Index(["a", "b", "c", "d", "e"], dtype=object))
6268

6369
# Join on string value
6470

pandas/tests/series/methods/test_map.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Index,
1515
MultiIndex,
1616
Series,
17+
bdate_range,
1718
isna,
1819
timedelta_range,
1920
)
@@ -154,8 +155,13 @@ def test_list_raises(string_series):
154155
string_series.map([lambda x: x])
155156

156157

157-
def test_map(datetime_series):
158-
index, data = tm.getMixedTypeDict()
158+
def test_map():
159+
data = {
160+
"A": [0.0, 1.0, 2.0, 3.0, 4.0],
161+
"B": [0.0, 1.0, 0.0, 1.0, 0.0],
162+
"C": ["foo1", "foo2", "foo3", "foo4", "foo5"],
163+
"D": bdate_range("1/1/2009", periods=5),
164+
}
159165

160166
source = Series(data["B"], index=data["C"])
161167
target = Series(data["C"][:4], index=data["D"][:4])
@@ -171,10 +177,14 @@ def test_map(datetime_series):
171177
for k, v in merged.items():
172178
assert v == source[target[k]]
173179

180+
181+
def test_map_datetime(datetime_series):
174182
# function
175183
result = datetime_series.map(lambda x: x * 2)
176184
tm.assert_series_equal(result, datetime_series * 2)
177185

186+
187+
def test_map_category():
178188
# GH 10324
179189
a = Series([1, 2, 3, 4])
180190
b = Series(["even", "odd", "even", "odd"], dtype="category")
@@ -185,6 +195,8 @@ def test_map(datetime_series):
185195
exp = Series(["odd", "even", "odd", np.nan])
186196
tm.assert_series_equal(a.map(c), exp)
187197

198+
199+
def test_map_category_numeric():
188200
a = Series(["a", "b", "c", "d"])
189201
b = Series([1, 2, 3, 4], index=pd.CategoricalIndex(["b", "c", "d", "e"]))
190202
c = Series([1, 2, 3, 4], index=Index(["b", "c", "d", "e"]))
@@ -194,6 +206,8 @@ def test_map(datetime_series):
194206
exp = Series([np.nan, 1, 2, 3])
195207
tm.assert_series_equal(a.map(c), exp)
196208

209+
210+
def test_map_category_string():
197211
a = Series(["a", "b", "c", "d"])
198212
b = Series(
199213
["B", "C", "D", "E"],

pandas/tests/util/test_hashing.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,14 @@ def test_multiindex_objects():
136136
DataFrame({"x": ["a", "b", "c"], "y": [1, 2, 3]}),
137137
DataFrame(),
138138
DataFrame(np.full((10, 4), np.nan)),
139-
tm.makeMixedDataFrame(),
139+
DataFrame(
140+
{
141+
"A": [0.0, 1.0, 2.0, 3.0, 4.0],
142+
"B": [0.0, 1.0, 0.0, 1.0, 0.0],
143+
"C": Index(["foo1", "foo2", "foo3", "foo4", "foo5"], dtype=object),
144+
"D": pd.date_range("20130101", periods=5),
145+
}
146+
),
140147
tm.makeTimeDataFrame(),
141148
tm.makeTimeSeries(),
142149
Series(tm.makePeriodIndex()),
@@ -162,7 +169,14 @@ def test_hash_pandas_object(obj, index):
162169
Series([True, False, True]),
163170
DataFrame({"x": ["a", "b", "c"], "y": [1, 2, 3]}),
164171
DataFrame(np.full((10, 4), np.nan)),
165-
tm.makeMixedDataFrame(),
172+
DataFrame(
173+
{
174+
"A": [0.0, 1.0, 2.0, 3.0, 4.0],
175+
"B": [0.0, 1.0, 0.0, 1.0, 0.0],
176+
"C": Index(["foo1", "foo2", "foo3", "foo4", "foo5"], dtype=object),
177+
"D": pd.date_range("20130101", periods=5),
178+
}
179+
),
166180
tm.makeTimeDataFrame(),
167181
tm.makeTimeSeries(),
168182
Series(tm.makePeriodIndex()),

0 commit comments

Comments
 (0)