Skip to content
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

API/DEPR: Rename DataFrame.applymap to DataFrame.map #52364

Merged

Conversation

topper-123
Copy link
Contributor

This PR builds on #52355, so could make sense to look at that first or ignore the first commit in this PR.

@topper-123 topper-123 changed the title API/DEPR: Rename data frame.applymap to data frame.map API/DEPR: Rename DataFrame.applymap to DataFrame.map Apr 2, 2023
@topper-123 topper-123 force-pushed the rename_DataFrame.applymap_to_DataFrame.map branch from 1b1ad9d to 70e50f3 Compare April 4, 2023 00:49
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, cc @pandas-dev/pandas-core for any thoughts

doc/source/user_guide/cookbook.rst Show resolved Hide resolved
pandas/core/frame.py Show resolved Hide resolved
pandas/core/frame.py Outdated Show resolved Hide resolved
@attack68
Copy link
Contributor

attack68 commented Apr 6, 2023

In the file: pandas/doc/source/user_guide/style.ipynb there is a linked reference to DataFrame.applymap in a cell, under "Methods to add styles". It is probably best to also relink this, now, to avoid it being forgotten and breaking later.

@topper-123
Copy link
Contributor Author

topper-123 commented Apr 6, 2023

Ok, I’ve done that @attack68.

@@ -352,7 +352,7 @@
"\n",
"- Using [.set_table_styles()][table] to control broader areas of the table with specified internal CSS. Although table styles allow the flexibility to add CSS selectors and properties controlling all individual parts of the table, they are unwieldy for individual cell specifications. Also, note that table styles cannot be exported to Excel. \n",
"- Using [.set_td_classes()][td_class] to directly link either external CSS classes to your data cells or link the internal CSS classes created by [.set_table_styles()][table]. See [here](#Setting-Classes-and-Linking-to-External-CSS). These cannot be used on column header rows or indexes, and also won't export to Excel. \n",
"- Using the [.apply()][apply] and [.applymap()][applymap] functions to add direct internal CSS to specific data cells. See [here](#Styler-Functions). As of v1.4.0 there are also methods that work directly on column header rows or indexes; [.apply_index()][applyindex] and [.applymap_index()][applymapindex]. Note that only these methods add styles that will export to Excel. These methods work in a similar way to [DataFrame.apply()][dfapply] and [DataFrame.applymap()][dfapplymap].\n",
"- Using the [.apply()][apply] and [.applymap()][applymap] functions to add direct internal CSS to specific data cells. See [here](#Styler-Functions). As of v1.4.0 there are also methods that work directly on column header rows or indexes; [.apply_index()][applyindex] and [.applymap_index()][applymapindex]. Note that only these methods add styles that will export to Excel. These methods work in a similar way to [DataFrame.apply()][dfapply] and [DataFrame.map()][dfmap].\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are changing DataFrame.applymap() to DataFrame.map(), shouldn't we then change Styler.applymap() to Styler.map() to make things consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a logical next step and @attack68 has proposed in #52353 (comment) to takie on styler.applymap after this has been merged.A good idea IMO.

@WillAyd
Copy link
Member

WillAyd commented Apr 6, 2023

Shouldn't we deprecate this before outright removing? Wouldn't this break user code for 2.1?

@jorisvandenbossche
Copy link
Member

Shouldn't we deprecate this before outright removing? Wouldn't this break user code for 2.1?

That's what the current code does I think

@WillAyd
Copy link
Member

WillAyd commented Apr 6, 2023

My mistake - totally misread that

@topper-123
Copy link
Contributor Author

Yes this PR just deprecates DataFrame.applymap.

@topper-123 topper-123 force-pushed the rename_DataFrame.applymap_to_DataFrame.map branch from dff4d63 to 415414d Compare April 7, 2023 20:06
@topper-123 topper-123 force-pushed the rename_DataFrame.applymap_to_DataFrame.map branch from 9a72424 to 8bad43b Compare April 7, 2023 20:19
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! Yeah the name applymap has confused me more than once

pandas/core/frame.py Outdated Show resolved Hide resolved
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment otherwise looks good

@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Apr 12, 2023
@mroeschke mroeschke added the Apply Apply, Aggregate, Transform label Apr 12, 2023
@mroeschke mroeschke added this to the 2.1 milestone Apr 12, 2023
@mroeschke
Copy link
Member

2023-04-14T22:44:55.0688278Z /home/runner/work/pandas/pandas/doc/source/whatsnew/v2.1.0.rst:249: WARNING: Inline interpreted text or phrase reference start-string without end-string.

@topper-123
Copy link
Contributor Author

Thanks,, I’ve updated.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a request on the whatsnew wording

doc/source/whatsnew/v2.1.0.rst Outdated Show resolved Hide resolved
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@topper-123
Copy link
Contributor Author

Updated.

@rhshadrach rhshadrach merged commit 75a79e7 into pandas-dev:main Apr 16, 2023
32 checks passed
@rhshadrach
Copy link
Member

Thanks @topper-123

@topper-123 topper-123 deleted the rename_DataFrame.applymap_to_DataFrame.map branch April 16, 2023 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: rename DataFrame.applymap -> DataFrame.map
8 participants