Skip to content

Commit

Permalink
TEST-#6932: don't use deprecated 'pandas._testing.makeStringIndex'
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
  • Loading branch information
anmyachev committed Feb 16, 2024
1 parent d54dcfd commit 1a6f9f3
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions asv_bench/benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ class TimeJoinStringIndex:

def setup(self, shapes, sort):
assert shapes[0] % 100 == 0, "implementation restriction"
level1 = tm.makeStringIndex(10).values
level2 = tm.makeStringIndex(shapes[0] // 100).values
level1 = IMPL.Index([f"i-{i}" for i in range(10)], dtype=object).values
level2 = IMPL.Index(
[f"i-{i}" for i in range(shapes[0] // 100)], dtype=object
).values
codes1 = np.arange(10).repeat(shapes[0] // 100)
codes2 = np.tile(np.arange(shapes[0] // 100), 10)
index2 = IMPL.MultiIndex(levels=[level1, level2], codes=[codes1, codes2])
Expand Down Expand Up @@ -897,8 +899,12 @@ def setup(self, shape):
self.df2 = IMPL.DataFrame(
index=range(rows), data=np.random.rand(rows, cols), columns=range(cols)
)
level1 = tm.makeStringIndex(rows // 10).values.repeat(10)
level2 = np.tile(tm.makeStringIndex(10).values, rows // 10)
level1 = IMPL.Index(
[f"i-{i}" for i in range(rows // 10)], dtype=object
).values.repeat(10)
level2 = np.tile(
IMPL.Index([f"i-{i}" for i in range(10)], dtype=object).values, rows // 10
)
index = IMPL.MultiIndex.from_arrays([level1, level2])
self.s = IMPL.Series(np.random.randn(rows), index=index)
self.s_subset = self.s[::2]
Expand Down Expand Up @@ -1033,7 +1039,9 @@ def setup(self, shape):
temp_df = DataFrame()
# dataframe would have cols-1 keys(strings) and one value(int) column
for col in range(cols - 1):
temp_df["key" + str(col + 1)] = tm.makeStringIndex(N).values.repeat(K)
temp_df["key" + str(col + 1)] = IMPL.Index(
[f"i-{i}" for i in range(N)], dtype=object
).values.repeat(K)
self.df = IMPL.DataFrame(temp_df)
self.df["value"] = np.random.randn(N * K)
execute(self.df)
Expand All @@ -1052,7 +1060,12 @@ class TimeDropDuplicatesSeries:

def setup(self, shape):
rows = shape[0]
self.series = IMPL.Series(np.tile(tm.makeStringIndex(rows // 10).values, 10))
self.series = IMPL.Series(
np.tile(
IMPL.Index([f"i-{i}" for i in range(rows // 10)], dtype=object).values,
10,
)
)
execute(self.series)

def time_drop_dups(self, shape):
Expand Down

0 comments on commit 1a6f9f3

Please sign in to comment.