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

Add Series.map #389

Merged
merged 3 commits into from May 29, 2019
Merged

Add Series.map #389

merged 3 commits into from May 29, 2019

Conversation

HyukjinKwon
Copy link
Member

This PR adds Series.map. If the function is given as an argument, seems we can just reuse apply.

>>> import pandas as pd
>>> pdf = pd.DataFrame({'a': [1,2,3,4,5,6]})
>>> pdf.a.apply(lambda x: x+  1)
0    2
1    3
2    4
3    5
4    6
5    7
Name: a, dtype: int64
>>> pdf.a.map(lambda x: x+  1)
0    2
1    3
2    4
3    5
4    6
5    7
Name: a, dtype: int64

See Also
--------
Series.apply : For applying more complex functions on a Series.
DataFrame.applymap : Apply a function elementwise on a whole DataFrame.
Copy link
Member Author

Choose a reason for hiding this comment

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

I will add this one soon.

@codecov-io
Copy link

codecov-io commented May 27, 2019

Codecov Report

Merging #389 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #389      +/-   ##
==========================================
+ Coverage   94.75%   94.77%   +0.02%     
==========================================
  Files          42       42              
  Lines        4554     4577      +23     
==========================================
+ Hits         4315     4338      +23     
  Misses        239      239
Impacted Files Coverage Δ
databricks/koalas/missing/series.py 100% <ø> (ø) ⬆️
databricks/koalas/series.py 93.95% <100%> (+0.36%) ⬆️
databricks/koalas/tests/test_series.py 100% <100%> (ø) ⬆️
databricks/koalas/generic.py 93.75% <0%> (-0.42%) ⬇️
databricks/koalas/frame.py 95.65% <0%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5fdff0a...512365e. Read the comment docs.


if hasattr(arg, "__missing__"):
tmp_val = arg[np._NoValue]
del arg[np._NoValue] # Remove in case it's set in defaultdict.
Copy link
Member Author

Choose a reason for hiding this comment

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

It's a hack to mimic Pandas's behaviour with defaultdict... but I believe basically the behaviours are matched when the input is a dictionary

Copy link
Contributor

Choose a reason for hiding this comment

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

Super cool! My only concern is that you are mutating 'arg', but this strikes me as an edge case for now.

@softagram-bot
Copy link

Softagram Impact Report for pull/389 (head commit: 512365e)

⭐ Change Overview

Showing the changed files, dependency changes and the impact - click for full size
(Open in Softagram Desktop for full details)

📄 Full report

Give feedback on this report to support@softagram.com

@HyukjinKwon HyukjinKwon merged commit 6e9b9e2 into databricks:master May 29, 2019
@ueshin ueshin mentioned this pull request Sep 26, 2019
@HyukjinKwon HyukjinKwon deleted the add_series_map branch September 11, 2020 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants