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

Implement DataFrame.map_in_pandas #1276

Merged
merged 1 commit into from
Feb 17, 2020

Conversation

HyukjinKwon
Copy link
Member

This PR implements a Koalas specific API in order to directly use pandas DataFrame APIs.

For pandas Series APIs, we have a workaround for instance:

>>> ks.range(10)[['id']].apply(lambda series: series)['id']
0    0
1    1
2    2
3    3
4    4
5    5
6    6
7    7
8    8
9    9
Name: id, dtype: int64

however, there is no way to use the APIs in the pandas DataFrame.

There is a similar API called map_partitions in Dask and this API is inspired by it.

@codecov-io
Copy link

codecov-io commented Feb 13, 2020

Codecov Report

Merging #1276 into master will decrease coverage by 0.06%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1276      +/-   ##
==========================================
- Coverage   95.15%   95.09%   -0.07%     
==========================================
  Files          34       34              
  Lines        7208     7236      +28     
==========================================
+ Hits         6859     6881      +22     
- Misses        349      355       +6
Impacted Files Coverage Δ
databricks/koalas/frame.py 96.47% <92.85%> (-0.06%) ⬇️
databricks/koalas/usage_logging/__init__.py 97.29% <0%> (ø) ⬆️
databricks/koalas/usage_logging/usage_logger.py 100% <0%> (ø) ⬆️
databricks/koalas/__init__.py 85.1% <0%> (-8.52%) ⬇️
databricks/conftest.py 96.22% <0%> (ø) ⬆️
databricks/koalas/namespace.py 87.87% <0%> (ø) ⬆️
databricks/koalas/plot.py 94.28% <0%> (ø) ⬆️
databricks/koalas/testing/utils.py 78.51% <0%> (ø) ⬆️
databricks/koalas/groupby.py 91.43% <0%> (ø) ⬆️
... and 1 more

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 6662ae6...fa8db4d. Read the comment docs.

@HyukjinKwon
Copy link
Member Author

@ueshin, let me merge this for now. The implementation is similar with DataFrame.apply so there won't be too many things to closely review.

Also, this PR has a reference from Dask, it allows many workarounds for example:

        >>> def take_func(pdf) -> ks.DataFrame[int, int]:
        ...     return pdf.query('A == 1')
        >>> df.map_in_pandas(take_func)

Let me know if you have any concern!

@HyukjinKwon HyukjinKwon merged commit 0799c83 into databricks:master Feb 17, 2020
HyukjinKwon pushed a commit that referenced this pull request Feb 18, 2020
As requested at #1273 (comment) ,

and since `map_in_pandas` (#1276 ) has been merged,

just uncommented existing doctest for DataFrame.query
@HyukjinKwon HyukjinKwon deleted the map_in_pandas branch September 11, 2020 07:52
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.

2 participants