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

fix DataFrame.applymap has been deprecated. #259

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ get a rough idea of the remaining amount of computation to be done.
| Without parallelization | With parallelization |
| --------------------------------------------------------- | ------------------------------------------------------------------ |
| `df.apply(func)` | `df.parallel_apply(func)` |
| `df.applymap(func)` | `df.parallel_applymap(func)` |
| `df.map(func)` | `df.parallel_applymap(func)` |
| `df.groupby(args).apply(func)` | `df.groupby(args).parallel_apply(func)` |
| `df.groupby(args1).col_name.rolling(args2).apply(func)` | `df.groupby(args1).col_name.rolling(args2).parallel_apply(func)` |
| `df.groupby(args1).col_name.expanding(args2).apply(func)` | `df.groupby(args1).col_name.expanding(args2).parallel_apply(func)` |
Expand Down
5 changes: 3 additions & 2 deletions docs/examples_mac_linux.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# DataFrame.applymap"
"# DataFrame.map"
]
},
{
Expand Down Expand Up @@ -135,7 +136,7 @@
"outputs": [],
"source": [
"%%time\n",
"res = df.applymap(func)"
"res = df.map(func)"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions docs/examples_windows.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# DataFrame.applymap"
"# DataFrame.map"
]
},
{
Expand Down Expand Up @@ -166,7 +167,7 @@
"outputs": [],
"source": [
"%%time\n",
"res = df.applymap(func)"
"res = df.map(func)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion pandarallel/data_types/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
user_defined_function_kwargs: Dict[str, Any],
extra: Dict[str, Any],
) -> pd.DataFrame:
return data.applymap(user_defined_function)
return data.map(user_defined_function)

Check warning on line 69 in pandarallel/data_types/dataframe.py

View check run for this annotation

Codecov / codecov/patch

pandarallel/data_types/dataframe.py#L69

Added line #L69 was not covered by tests

@staticmethod
def reduce(
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ classifiers =

[options]
packages = find:
python_requires = >=3.7
python_requires = >=3.9
install_requires =
dill >= 0.3.1
pandas >= 1
pandas >= 2.1.0
psutil

[options.packages.find]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pandarallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ def test_dataframe_apply_invalid_axis(pandarallel_init):
df.parallel_apply(lambda x: x, axis="invalid")


def test_dataframe_applymap(pandarallel_init, func_dataframe_applymap, df_size):
def test_dataframe_map(pandarallel_init, func_dataframe_applymap, df_size):
df = pd.DataFrame(
dict(a=np.random.randint(1, 8, df_size), b=np.random.rand(df_size))
)
df.index = [item / 10 for item in df.index]

res = df.applymap(func_dataframe_applymap)
res = df.map(func_dataframe_applymap)
res_parallel = df.parallel_applymap(func_dataframe_applymap)
assert res.equals(res_parallel)

Expand Down
Loading