Skip to content

CLN/ASV: DataFrame.applymap (deprecated) -> DataFrame.map #54221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/io/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def setup(self, sep, thousands, engine):
if thousands is not None:
fmt = f":{thousands}"
fmt = "{" + fmt + "}"
df = df.applymap(lambda x: fmt.format(x))
df = df.map(lambda x: fmt.format(x))
df.to_csv(self.fname, sep=sep)

def time_thousands(self, sep, thousands, engine):
Expand Down
6 changes: 3 additions & 3 deletions asv_bench/benchmarks/io/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def time_write_excel_style(self, engine):
bio.seek(0)
with ExcelWriter(bio, engine=engine) as writer:
df_style = self.df.style
df_style.applymap(lambda x: "border: red 1px solid;")
df_style.applymap(lambda x: "color: blue")
df_style.applymap(lambda x: "border-color: green black", subset=["float1"])
df_style.map(lambda x: "border: red 1px solid;")
df_style.map(lambda x: "color: blue")
df_style.map(lambda x: "border-color: green black", subset=["float1"])
df_style.to_excel(writer, sheet_name="Sheet1")


Expand Down
4 changes: 2 additions & 2 deletions asv_bench/benchmarks/io/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _apply_func(s):
self.st = self.df.style.apply(_apply_func, axis=1)

def _style_classes(self):
classes = self.df.applymap(lambda v: ("cls-1" if v > 0 else ""))
classes = self.df.map(lambda v: ("cls-1" if v > 0 else ""))
classes.index, classes.columns = self.df.index, self.df.columns
self.st = self.df.style.set_td_classes(classes)

Expand All @@ -80,7 +80,7 @@ def _style_format(self):
)

def _style_apply_format_hide(self):
self.st = self.df.style.applymap(lambda v: "color: red;")
self.st = self.df.style.map(lambda v: "color: red;")
self.st.format("{:.3f}")
self.st.hide(self.st.index[1:], axis=0)
self.st.hide(self.st.columns[1:], axis=1)
Expand Down